def tick(self):
if self.state and self.state.mode == LightState.RUNNING:
p_loc = (self.state.pacman.x, self.state.pacman.y)
# update game state
if self.grid[p_loc[0]][p_loc[1]] in [o, O]:
self.grid[p_loc[0]][p_loc[1]] = e
path = bfs(self.grid, p_loc, self.state, [o, O])
print(path)
if path != None:
next_loc = path[1]
# Figure out position we need to move
new_msg = PacmanCommand()
new_msg.dir = self._get_direction(p_loc, next_loc)
self.write(new_msg.SerializeToString(), MsgType.PACMAN_COMMAND)
return
new_msg = PacmanCommand()
new_msg.dir = PacmanCommand.STOP
self.write(new_msg.SerializeToString(), MsgType.PACMAN_COMMAND)
评论列表
文章目录