manager.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:robot-arena 作者: kenganong 项目源码 文件源码
def perform_moves(state, interactive):
  to_move = [cell.content for cell, pos in state.board.traverse() if cell.content and cell.content[TYPE] == ROBOT
                and cell.content['move'] in [TURN_LEFT, TURN_RIGHT, U_TURN]]
  for robot in to_move:
    perform_turn(robot, robot['move'])
  to_move = [pos for cell, pos in state.board.traverse() if cell.content and cell.content[TYPE] == ROBOT
                and cell.content['move'] in [FORWARD, REVERSE]]
  random.shuffle(to_move)
  while len(to_move) > 0:
    pos = to_move.pop()
    robot = state.board.get_item(pos).content
    if robot['move'] == FORWARD:
      direction = robot[FACING]
    elif robot['move'] == REVERSE:
      direction = opposite_direction(robot[FACING])
    perform_move_in_direction(state, pos, direction, to_move, interactive)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号