def main(): new_hook = pyxhook.HookManager() new_hook.KeyDown = OnKeyPress new_hook.HookKeyboard() new_hook.start() screen = test() global key paused = False while (True): if not paused: screen = test() start_time = time.time() prediction = model.predict([screen.reshape(300, 100, 55, 3)])[0] prediction = np.array(prediction) mode_choice = np.argmax(prediction) end_time = time.time() qwerty = end_time - start_time print(qwerty) if mode_choice == 0: straight() choice_picked = 'straight' elif mode_choice == 1: reverse() choice_picked = 'reverse' elif mode_choice == 2: left() choice_picked = 'left' elif mode_choice == 3: right() choice_picked = 'right' elif mode_choice == 4: strafe_right() choice_picked = 'strafe_right' elif mode_choice == 5: strafe_left() choice_picked = 'strafe_left' elif mode_choice == 6: no_keys() choice_picked = 'no_keys' # p pauses game and can get annoying. if key == 116: if paused: paused = False print('UnPaused') key = 0 else: paused = True print('Paused') key = 0
def main(): new_hook=pyxhook.HookManager() new_hook.KeyDown=OnKeyPress new_hook.HookKeyboard() new_hook.start() screen = test() global key paused =True while(True): #if not paused: screen = test() start_time = time.time() prediction = model.predict([screen.reshape(-1,timesteps,WIDTH,HEIGHT,3)])[0] prediction = np.array(prediction) mode_choice = np.argmax(prediction) end_time = time.time() qwerty = end_time - start_time print(qwerty) if mode_choice == 0: straight() choice_picked = 'straight' elif mode_choice == 1: reverse() choice_picked = 'reverse' elif mode_choice == 2: left() choice_picked = 'left' elif mode_choice == 3: right() choice_picked = 'right' elif mode_choice == 4: strafe_right() choice_picked = 'strafe_right' elif mode_choice == 5: strafe_left() choice_picked = 'strafe_left' elif mode_choice == 6: no_keys() choice_picked = 'no_keys'
def main(): new_hook=pyxhook.HookManager() new_hook.KeyDown=OnKeyPress new_hook.HookKeyboard() new_hook.start() screen = test() global key paused =True while(True): if not paused: screen = test() prediction = model.predict([screen.reshape(WIDTH,HEIGHT,1)])[0] prediction = np.array(prediction) mode_choice = np.argmax(prediction) if mode_choice == 0: straight() elif mode_choice == 1: left() elif mode_choice == 2: right() elif mode_choice == 3: no_keys() elif mode_choice == 4: junction() # p pauses game and can get annoying. if key == 116: if paused: paused = False print('UnPaused') key = 0 else: paused = True print('Paused') key = 0 if time.time() - start_time >= 10.0 : check_junction = True