def __init__(self, addr, port): self.subscriptions = [MsgType.PACMAN_LOCATION] super().__init__(addr, port, message_buffers, MsgType, FREQUENCY, self.subscriptions) self.loop.add_reader(sys.stdin, self.keypress) self.game = GameState()
def __init__(self, addr, port): self.subscriptions = [ MsgType.PACMAN_LOCATION, MsgType.FULL_STATE, MsgType.LIGHT_STATE ] super().__init__(addr, port, message_buffers, MsgType, FREQUENCY, self.subscriptions) self.loop.add_reader(sys.stdin, self.keypress) self.game = GameState() self.pacbot_pos = [pacbot_starting_pos[0], pacbot_starting_pos[1]] self.cur_dir = right self.next_dir = right self.state = PacmanState() self.state.mode = PacmanState.PAUSED self.lives = starting_lives self.clicks = 0 self.light_state = StateConverter.convert_game_state_to_light( self.game)
def __init__(self, addr, port): self.subscriptions = [MsgType.PACMAN_LOCATION] super().__init__(addr, port, message_buffers, MsgType, FREQUENCY, self.subscriptions) self.game = GameState() self.game.unpause()
def __init__(self, addr, port): # GameEngine.__init__(self, addr, port) self.subscriptions = [MsgType.PACMAN_LOCATION] super().__init__(addr, port, message_buffers, MsgType, FREQUENCY, self.subscriptions) self.game = GameState() self.loop.add_reader(self.game._should_die():, self.keypress)
def __init__(self, addr, port, weight_set=WEIGHT_SET, run_on_clock=None, using_visualizer=None): global WEIGHT_SET, USING_VISUALIZER, RUN_ON_CLOCK if run_on_clock is not None: RUN_ON_CLOCK = run_on_clock if using_visualizer is not None: USING_VISUALIZER = using_visualizer WEIGHT_SET = weight_set self.final_state = None self.latestPacbotInfo = None self.subscriptions = [MsgType.PACMAN_LOCATION] # super().__init__(addr, port, message_buffers, MsgType, FREQUENCY, self.subscriptions) # self.loop.add_reader(sys.stdin, self.keypress) self.game = GameState() self.highLevelPacman = HighLevelPacman( addr=None, port=None, game=self, returnInfo=NO_PRINT, frequency_multiplier=FREQUENCY_MULTIPLIER, fear=WEIGHT_SET['FEAR'], pellet_weight=WEIGHT_SET['PELLET_WEIGHT'], super_pellet_weight=WEIGHT_SET['SUPER_PELLET_WEIGHT'], ghost_weight=WEIGHT_SET['GHOST_WEIGHT'], frightened_ghost_weight=WEIGHT_SET['FRIGHTENED_GHOST_WEIGHT'], proximity_pellet_multiplier=WEIGHT_SET[ 'PROXIMITY_PELLET_MULTIPLIER'], anti_corner_weight=WEIGHT_SET['ANTI_CORNER_WEIGHT'], runOnClock=RUN_ON_CLOCK) if USING_VISUALIZER: self.visualize = Visualize(run_on_clock=run_on_clock) self.game.unpause() if RUN_ON_CLOCK: self.loop = asyncio.get_event_loop() self.loop.call_soon(self.tick) else: turn_num = 0 while self.game.play: turn_num += 1 if VALUE_DEBUG: # export data to debug/visualize the heuristic values self.export_heuristic_debug(f'data/data{turn_num:05}.pkl') # INCORRECT CALL TIMING, PACBOT MOVES WAY TOO FAST # update_pacbot_pos self.highLevelPacman.tick() # This will become asynchronous for i in range(8): self.game.next_step() if USING_VISUALIZER: self.visualize.visualizer.msg_received( StateConverter.convert_game_state_to_full( self.game), MsgType.FULL_STATE) self.highLevelPacman.msg_received( StateConverter.convert_game_state_to_light(self.game), MsgType.LIGHT_STATE) # print('gameEngineTickMesg') # print('SAVE GAME STATE TO FILE') if USING_VISUALIZER: pygame.time.wait(50) self.final_state = {'score': self.game.score}