def move(board, robot, robots, statistics, url): robot.robots = map(lambda r: r[0].position, robots) robot.allowedMoves = board.getAllowedMoves(robot.position) newPosition, newSpeed, newVelocity = get_move(url, robot) board.moveRobot(robot.position, newPosition, newSpeed, newVelocity) if robot.position != newPosition or robot.position not in robot.destination: statistics[robot.id] = statistics.get(robot.id, 0) + 1 robot.setOwnPosition(newPosition) robot.setVelocity(newVelocity) robot.setSpeed(newSpeed)
def ask_robot(moves, robot, url): print "asking..." robot.robots = map(lambda r: r[0].position, robots) robot.allowedMoves = board.getAllowedMoves(robot.position) newPosition, newSpeed, newVelocity = get_move(url, robot) moves.append((robot, newPosition, newSpeed, newVelocity))