Best Python code snippet using autotest_python
evolution.py
Source:evolution.py
1#!/usr/bin/python2# -*- coding:UTF-8 -*-3import random4from Tkinter import *5from battle import *6from tkMessageBox import *7def move_char_judage(key_press):8 'å®ä¹ è¾å
¥ --- ç§»å¨ ç对åºå
³ç³»'9 if key_press == 'w' or key_press == 'W':10 move_step = [-1, 0]11 elif key_press == 's' or key_press == 'S':12 move_step = [1, 0]13 elif key_press == 'a' or key_press == 'A':14 move_step = [0, -1]15 elif key_press == 'd' or key_press == 'D': 16 move_step = [0, 1]17 else:18 move_step = [0, 0]19 return move_step20def find_hero(map_data):21 'ç¡®å®è±éçä½ç½®'22 hero_pos = [0,0]23 for search_width in range(len(map_data)):24 for search_length in range(len(map_data[0])):25 if map_data[search_width][search_length] == -1:26 hero_pos[0] = search_width27 hero_pos[1] = search_length28 return hero_pos29def cat_next_block(map_data, key_press):30 'è·åä¸ä¸ä¸ªæ¹æ ¼çåæ '31 hero_pos = find_hero(map_data)32 hero_move = move_char_judage(key_press)33 next_step = hero_pos34 next_step = [hero_pos[0]+hero_move[0], hero_pos[1]+hero_move[1]]35 return next_step36def jud_go(map_data, key_press):37 'å¤æä¸ä¸ä¸ªæ¹æ ¼æ¯å¦è½èµ°'38 hero_pos = find_hero(map_data)39 next_step = cat_next_block(map_data, key_press)40 if map_data[next_step[0]][next_step[1]] == 1: #å¦æåæ¹æ¯ç³å41 move_def = 142 elif map_data[next_step[0]][next_step[1]] == 99:43 move_def = 9944 elif next_step[0]>len(map_data)-2 \45 or (next_step[1]>len(map_data[0])-2 \46 or next_step[0]<0 \47 or next_step[1]<0): #å¦æå·²å°è¾¾è¾¹ç48 move_def = -149 else:50 move_def = 051 return move_def52def update_map_data(hero_property, map_data, key_press):53 hero_pos = find_hero(map_data)54 next_step = cat_next_block(map_data, key_press)55 56 move_define = jud_go(map_data, key_press)57 58 if move_define == 0:59 map_data[hero_pos[0]][hero_pos[1]] = 060 map_data[next_step[0]][next_step[1]] = -1 #èµ°è¿çä½ç½®å为æ®éæ¹åï¼ä¸ä¸ä½ç½®å为è±éæå¨ä½ç½®61 elif move_define == 1 and hero_property['rock_destory']:62 map_data[hero_pos[0]][hero_pos[1]] = 063 map_data[next_step[0]][next_step[1]] = -164 return map_data65def block_activity(root, hero_property, map_data, key_press, difficulty):66 'å¨æ®éæ¹åä¸, éæºçææªç©'67 next_step = cat_next_block(map_data, key_press)68 next_element = map_data[next_step[0]][next_step[1]]69 re_property = hero_property70 71 jud_continue = 072 if next_element == 1:73 if askyesno("讨åçç³å¤´",'æ¯å¦è¦æç ´ç³å¤´'):74 hero_property['rock_destory'] = True75 re_property = battle_creat(root, hero_property, difficulty, 1)76 elif next_element == 2:77 re_property = heal_hero(hero_property, difficulty)78 elif next_element == 3:79 re_property = battle_creat(root, hero_property, difficulty,3)80 elif next_element == 98:81 re_property = find_key(hero_property)82 elif next_element == 99: 83 if hero_property['key'] == 'FOUND!':84 if level_clear(hero_property):85 jud_continue = 186 else:87 jud_continue = -188 else:89 showinfo(title = 'é¨é', message = 'æ¨è¿æ²¡æé¥å, é¥åä¼éæºåºç°å¨è¥å°(æ©è²æ¹å)å½ä¸')90 else:91 if random.random() < 0.15 * difficulty:92 re_property = battle_creat(root, hero_property, difficulty, 0)93 return jud_continue, re_property94def level_clear(hero_property):95 if hero_property['esp'] > 10:96 showinfo(title = 'æå°±', message = hero_property['name']+'ä¸å±ä¸éè·è¶
è¿å次, è·å¾â以æ æèææâç称å·...')97 if hero_property['esp'] == 0:98 showinfo(title = 'æå°±', message = hero_property['name']+'ä¸å±ä¸ä»æªéè·ä¸å±, è·å¾âä¸æ,å°±æ¯å¹²!âç称å·...')99 choice_continue = askyesno("Skyround",'æ¯å¦ç»§ç»æ¢ç´¢ä¸ä¸åºå')...
1.0.py
Source:1.0.py
1def preparation(x_1, x_2):2 for i in x_1:3 y_1 = i4 y_2 = i5 y_3 = i6 y = [y_1, y_2, y_3]7 x_2.append(y)8def step(initial, final):9 for j in initial:10 primordial = j[0]11 going = j[1]12 check = j[2]13 if primordial not in next_step:14 if going % (2**n) == 0:15 going = going // (2**n)16 check = check / (2**n)17 if primordial < check:18 next_step.append(primordial)19 elif going % 2 == 1:20 going = 3*going+121 check = 3*check+122 while going > 10**n:23 going = going - 10**n24 y = [primordial, going, check]25 final.append(y)26 elif going % 2 == 0:27 going = going//228 check = check/229 if primordial < check:30 y = [primordial, going, check]31 final.append(y)32 going = going+((10**n)/2)33 while going > 10 ** n:34 going = going - 10 ** n35 y = [primordial, going, check]36 final.append(y)37next_step = []38n = 139zero = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]40numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]41initial = []42preparation(zero, initial)43final = []44for i in range(1, 100):45 step(initial, final)46 initial = final47 final = []48print(len(next_step), next_step)49zero = []50for i in numbers:51 for j in next_step:52 y = j + i*(10**n)53 zero.append(y)54n = 255next_step = []56initial = []57preparation(zero, initial)58final = []59for i in range(1, 100):60 step(initial, final)61 initial = final62 final = []63print(len(next_step), next_step)64zero = []65for i in numbers:66 for j in next_step:67 y = j + i*(10**n)68 zero.append(y)69n = 370next_step = []71initial = []72preparation(zero, initial)73final = []74for i in range(1, 100):75 step(initial, final)76 initial = final77 final = []78print(len(next_step), next_step)79zero = []80for i in numbers:81 for j in next_step:82 y = j + i*(10**n)83 zero.append(y)84n = 485next_step = []86initial = []87preparation(zero, initial)88final = []89for i in range(1, 100):90 step(initial, final)91 initial = final92 final = []93print(len(next_step), next_step)94zero = []95for i in numbers:96 for j in next_step:97 y = j + i*(10**n)98 zero.append(y)99n = 5100next_step = []101initial = []102preparation(zero, initial)103final = []104for i in range(1, 100):105 step(initial, final)106 initial = final107 final = []...
rs_model_test.py
Source:rs_model_test.py
1import math2import pytest3from src import rs_model4@pytest.fixture()5def model():6 return rs_model.RSModel()7@pytest.fixture()8def zero_pos():9 return [0.0, 0.0, 0.0]10def test_step_straight(model, zero_pos):11 next_step = model.step(zero_pos, 0.0, 1.0)12 assert next_step == (1.0, 0.0, 0.0)13def test_step_straight_with_turn(model, zero_pos):14 next_step = model.step(zero_pos, 1.0, 1.0)15 assert next_step == (1.0, 0.0, 1.0)16def test_step_turn_with_turn(model, zero_pos):17 next_step = model.step(zero_pos, 1.0, math.pi/8)18 assert next_step[0] == 1.0 and next_step[1] == 0.019 current_yaw = next_step[2]20 next_step = model.step(next_step, 1.0, math.pi/8)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!