def __init__(self, p_game_state): super().__init__(p_game_state) self.add_tactic(0, Stop(self.game_state, 0)) self.add_tactic( 0, GoStraightTo(self.game_state, 0, Pose(Position(-500, -500)))) self.add_tactic( 0, GoStraightTo(self.game_state, 0, Pose(Position(-1500, -1500)))) self.add_condition(0, 0, 1, self.condition2) self.add_condition(0, 1, 2, self.condition) self.add_condition(0, 2, 0, self.condition) self.add_tactic(1, GoStraightTo(self.game_state, 1, Pose(Position(0, 0)))) self.add_tactic( 1, GoStraightTo(self.game_state, 1, Pose(Position(1000, 0)))) self.add_tactic( 1, GoStraightTo(self.game_state, 1, Pose(Position(1000, 1000)))) self.add_tactic( 1, GoStraightTo(self.game_state, 1, Pose(Position(0, 1000)))) self.add_condition(1, 0, 1, self.condition1) self.add_condition(1, 1, 2, self.condition1) self.add_condition(1, 2, 3, self.condition1) self.add_condition(1, 3, 0, self.condition1) for i in range(2, 6): self.add_tactic(i, Stop(self.game_state, i))
def __init__(self, p_game_state): super().__init__(p_game_state) self.passing_ID = 5 self.player_ID_no1 = 2 self.player_ID_no2 = 3 self.goal_ID = None self.goal = (Pose(Position(self.game_state.const["FIELD_GOAL_YELLOW_X_LEFT"], 0), 0)) self.add_tactic(self.passing_ID, Stop(self.game_state, self.passing_ID)) self.add_tactic(self.passing_ID, PassToPlayer(self.game_state, self.passing_ID, target_id=self.player_ID_no1)) self.add_tactic(self.passing_ID, PassToPlayer(self.game_state, self.passing_ID, target_id=self.player_ID_no2)) self.add_tactic(self.passing_ID, GoKick(self.game_state, self.passing_ID, self.goal)) self.add_condition(self.passing_ID, 0, 1, partial(self.is_best_receiver, self.player_ID_no1)) self.add_condition(self.passing_ID, 0, 2, partial(self.is_best_receiver, self.player_ID_no2)) self.add_condition(self.passing_ID, 0, 3, partial(self.is_best_receiver, None)) self.add_condition(self.passing_ID, 1, 0, partial(self.condition, self.passing_ID)) self.add_condition(self.passing_ID, 2, 0, partial(self.condition, self.passing_ID)) self.add_condition(self.passing_ID, 3, 0, partial(self.condition, self.passing_ID)) for i in range(PLAYER_PER_TEAM): if not (i == self.passing_ID): self.add_tactic(i, Stop(self.game_state, i))
def __init__(self, p_game_state): tactics = [ GoToPositionNoPathfinder(p_game_state, 0), Stop(p_game_state, 1), Stop(p_game_state, 2), Stop(p_game_state, 3), Stop(p_game_state, 4), Stop(p_game_state, 5) ] super().__init__(p_game_state, tactics)
def __init__(self, p_game_state): super().__init__(p_game_state) self.add_tactic(0, GoalKeeper(self.game_state, 0)) for i in range(1, PLAYER_PER_TEAM): self.add_tactic(i, Stop(self.game_state, i))
def __init__(self, p_game_state): super().__init__(p_game_state) self.goalkeeper = 3 self.passing_robot = 5 self.receiver = 4 goal1 = Pose(Position(-1636, 0)) goal2 = Pose(Position(1636, 0)) self.add_tactic(self.goalkeeper, GoalKeeper(self.game_state, self.goalkeeper)) receiver_pose = Pose(Position(-500, -500)) self.add_tactic( self.receiver, PositionForPass(self.game_state, self.receiver, receiver_pose)) self.add_tactic(self.receiver, GoKick(self.game_state, self.receiver, goal1)) self.add_condition( self.receiver, 0, 1, partial(self.is_passing_robot_success, self.receiver)) self.add_condition( self.receiver, 1, 0, partial(self.has_receiver_kicked_to_goal, self.receiver)) self.add_tactic( self.passing_robot, Capture(self.game_state, self.passing_robot, receiver_pose)) self.add_tactic( self.passing_robot, GoKick(self.game_state, self.passing_robot, receiver_pose)) self.add_tactic(self.passing_robot, Stop(self.game_state, self.passing_robot)) self.add_condition(self.passing_robot, 0, 1, partial(self.is_receiver_ready, self.passing_robot)) self.add_condition( self.passing_robot, 1, 2, partial(self.is_passing_robot_success, self.passing_robot)) self.add_condition( self.passing_robot, 2, 0, partial(self.has_receiver_kicked_to_goal, self.passing_robot)) self.add_condition(self.passing_robot, 2, 1, partial(self.is_receiver_ready, self.passing_robot)) for i in range(PLAYER_PER_TEAM): if not (i == self.goalkeeper or i == self.passing_robot or i == self.receiver): self.add_tactic(i, Stop(self.game_state, i))
def __init__(self, p_game_state): super().__init__(p_game_state) # ID Robot Indiana Jones : 0 # ID Robot obstacles mouvants : 1 et 2 indiana = self.game_state.my_team.available_players[4] obs_right = self.game_state.my_team.available_players[5] obs_left = self.game_state.my_team.available_players[3] # Positions objectifs d'Indiana Jones goal_left = (Pose( Position(self.game_state.const["FIELD_GOAL_YELLOW_X_LEFT"], 0), 0)) goal_right = (Pose( Position(self.game_state.const["FIELD_GOAL_BLUE_X_RIGHT"], 0), 0)) # Positions objectifs des obstacles y_down = self.game_state.const["FIELD_Y_BOTTOM"] + 500 y_top = self.game_state.const["FIELD_Y_TOP"] - 500 x_left = self.game_state.const["FIELD_X_LEFT"] + 500 x_right = self.game_state.const["FIELD_X_RIGHT"] - 500 self.add_tactic( indiana.id, GoToPositionPathfinder(self.game_state, indiana, goal_left)) self.add_tactic( indiana.id, GoToPositionPathfinder(self.game_state, indiana, goal_right)) self.add_condition(indiana.id, 0, 1, partial(self.condition, indiana)) self.add_condition(indiana.id, 1, 0, partial(self.condition, indiana)) self.add_tactic( obs_left.id, GoToPositionPathfinder(self.game_state, obs_left, Pose(Position(x_left / 2, y_top)))) self.add_tactic( obs_left.id, GoToPositionPathfinder(self.game_state, obs_left, Pose(Position(x_left / 2, y_down)))) self.add_condition(obs_left.id, 0, 1, partial(self.condition, obs_left)) self.add_condition(obs_left.id, 1, 0, partial(self.condition, obs_left)) self.add_tactic( obs_right.id, GoToPositionPathfinder(self.game_state, obs_right, Pose(Position(x_right / 2, y_top)))) self.add_tactic( obs_right.id, GoToPositionPathfinder(self.game_state, obs_right, Pose(Position(x_right / 2, y_down)))) self.add_condition(obs_right.id, 0, 1, partial(self.condition, obs_right)) self.add_condition(obs_right.id, 1, 0, partial(self.condition, obs_right)) for i in range(PLAYER_PER_TEAM): if not (i == obs_right.id or i == obs_left.id or i == indiana.id): self.add_tactic(i, Stop(self.game_state, i))
def setUp(self): self.game_state = GameState() self.game_state._update_player(0, Pose(Position(-4450, 0), 0)) self.tactic1 = GoalKeeper(self.game_state, 0) self.tactic2 = Stop(self.game_state, 1) self.node1 = Node(self.tactic1) self.node2 = Node(self.tactic2) self.vertex1 = Vertex(0, foo) self.vertex2 = Vertex(1, foo2)
def setUp(self): self.game_state = GameState() self.empty_graph = Graph() self.graph1 = Graph() self.tactic1 = Stop(self.game_state, 1) self.tactic2 = GoToPosition(self.game_state, 0, Pose(Position(500, 0), 0)) self.node1 = Node(self.tactic1) self.node2 = Node(self.tactic2) self.vertex1 = Vertex(1, foo) self.graph1.add_node(self.node1) self.graph1.add_node(self.node2) self.graph1.add_vertex(0, 1, foo)
def __init__(self, p_game_state): super().__init__(p_game_state) # TODO: modification en temps reel de la position de la balle self.designated_robot = 0 self.position_to_shoot_to = Position(0, 0) self.origin = self.game_state.get_ball_position() tactic = RotateAround(self.game_state, self.designated_robot, self.origin, self.position_to_shoot_to) self.add_tactic(self.designated_robot, tactic) # le reste des robots sont a l'arret for robot_to_stop in range(0, 6): if robot_to_stop != self.designated_robot: self.add_tactic(robot_to_stop, Stop(self.game_state, robot_to_stop))
def setUp(self): config_service = ConfigService().load_file("config/sim_standard.cfg") self.game_state = GameState() self.game = Game() self.game.set_referee(Referee()) self.game.ball = Ball() game_world = ReferenceTransferObject(self.game) game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW_TEAM)) self.game_state.set_reference(game_world) self.game_state.game.friends.players[0].update( Pose(Position(-4450, 0), 0)) self.tactic1 = GoalKeeper(self.game_state, 0) self.tactic2 = Stop(self.game_state, 1) self.node1 = Node(self.tactic1) self.node2 = Node(self.tactic2) self.vertex1 = Vertex(0, foo) self.vertex2 = Vertex(1, foo2)
def __init__(self, p_game_state): super().__init__(p_game_state) robot1 = self.game_state.my_team.available_players[4] robot2 = self.game_state.my_team.available_players[2] robot3 = self.game_state.my_team.available_players[3] self.add_tactic(robot1.id, DemoFollowBall(self.game_state, robot1)) self.add_tactic( robot2.id, DemoFollowRobot(self.game_state, robot2, args=[robot1.id])) self.add_tactic( robot3.id, DemoFollowRobot(self.game_state, robot3, args=[robot2.id])) for player in self.game_state.my_team.available_players.values(): if not (player.id == robot1.id or player.id == robot2.id or player.id == robot3.id): self.add_tactic(player.id, Stop(self.game_state, player))
def setUp(self): config_service = ConfigService().load_file("config/sim_standard.cfg") self.game_state = GameState() self.game = Game() self.game.set_referee(Referee()) self.game.ball = Ball() game_world = ReferenceTransferObject(self.game) game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW_TEAM)) self.game_state.set_reference(game_world) self.game_state = GameState() self.empty_graph = Graph() self.graph1 = Graph() self.tactic1 = Stop(self.game_state, 1) self.tactic2 = GoToPositionNoPathfinder(self.game_state, 0, Pose(Position(500, 0), 0)) self.node1 = Node(self.tactic1) self.node2 = Node(self.tactic2) self.vertex1 = Vertex(1, foo) self.graph1.add_node(self.node1) self.graph1.add_node(self.node2) self.graph1.add_vertex(0, 1, foo)
def __init__(self, p_game_state): super().__init__(p_game_state) self.add_tactic(0, GoalKeeper(self.game_state, 0)) self.add_tactic( 1, GoStraightTo(self.game_state, 1, Pose(Position(), 3 * pi / 2))) self.add_tactic( 1, GoStraightTo(self.game_state, 1, Pose(Position(1000, 0), 0))) self.add_tactic( 1, GoStraightTo(self.game_state, 1, Pose(Position(1000, 1000), pi / 2))) self.add_tactic( 1, GoStraightTo(self.game_state, 1, Pose(Position(0, 1000), pi))) self.add_condition(1, 0, 1, self.condition) self.add_condition(1, 1, 2, self.condition) self.add_condition(1, 2, 3, self.condition) self.add_condition(1, 3, 0, self.condition) for i in range(2, PLAYER_PER_TEAM): self.add_tactic(i, Stop(self.game_state, i))
def __init__(self, game_state): super().__init__(game_state) self.passer_id = 1 self.passer_position = self.game_state.get_player_pose( self.passer_id).position self.receiver_id = 2 self.receiver_pose = self.game_state.get_player_pose(self.receiver_id) self.ball_position = self.game_state.get_ball_position() self.add_tactic(0, GoalKeeper(self.game_state, 0)) self.add_tactic( self.passer_id, GoGetBall(self.game_state, self.passer_id, self.receiver_pose, None)) self.add_tactic( self.passer_id, RotateAround(self.game_state, self.passer_id, self.ball_position, self.receiver_pose.position)) self.add_tactic( self.passer_id, PassBall(self.game_state, self.passer_id, self.receiver_pose, None)) self.add_condition(self.passer_id, 0, 1, self.passer_has_ball) self.add_condition(self.passer_id, 1, 2, self.ready_to_pass) self.add_condition(self.passer_id, 2, 0, self.pass_failed) p = Pose(self.receiver_pose.position, get_angle(self.receiver_pose.position, self.ball_position)) self.add_tactic( self.receiver_id, GoToPositionNoPathfinder(self.game_state, self.receiver_id, p)) self.add_tactic(self.receiver_id, ReceivePass(self.game_state, self.receiver_id, p)) self.add_condition(self.receiver_id, 0, 1, self.pass_was_made) for i in range(3, PLAYER_PER_TEAM): self.add_tactic(i, Stop(self.game_state, i))
def __init__(self, p_game_state): super().__init__(p_game_state) for player in self.game_state.my_team.available_players.values(): self.add_tactic(player.id, Stop(self.game_state, player))
def __init__(self, p_game_state): super().__init__(p_game_state) for i in range(PLAYER_PER_TEAM): self.add_tactic(i, Stop(self.game_state, i))
def __init__(self, p_game_state): super().__init__(p_game_state) # Robot 0 self.add_tactic( 0, GoToPositionPathfinder(self.game_state, 0, Pose(Position(-1500, 1500)))) self.add_tactic( 0, GoToPositionPathfinder(self.game_state, 0, Pose(Position(1500, 1500)))) self.add_tactic( 0, GoToPositionPathfinder(self.game_state, 0, Pose(Position(1500, -1500)))) self.add_tactic( 0, GoToPositionPathfinder(self.game_state, 0, Pose(Position(-1500, -1500)))) self.add_condition(0, 0, 1, self.condition0) self.add_condition(0, 1, 2, self.condition0) self.add_condition(0, 2, 3, self.condition0) self.add_condition(0, 3, 1, self.condition0) # Robot 1 self.add_tactic( 1, GoToPositionPathfinder(self.game_state, 0, Pose(Position(2000, -2000)))) self.add_tactic( 1, GoToPositionPathfinder(self.game_state, 0, Pose(Position(-2000, 2000)))) self.add_tactic( 1, GoToPositionPathfinder(self.game_state, 0, Pose(Position(2000, 2000)))) self.add_tactic( 1, GoToPositionPathfinder(self.game_state, 0, Pose(Position(-2000, -2000)))) self.add_condition(1, 0, 1, self.condition1) self.add_condition(1, 1, 2, self.condition1) self.add_condition(1, 2, 3, self.condition1) self.add_condition(1, 3, 1, self.condition1) # Robot 2 self.add_tactic( 2, GoToPositionPathfinder(self.game_state, 0, Pose(Position(0, 2100)))) self.add_tactic( 2, GoToPositionPathfinder(self.game_state, 0, Pose(Position(0, 2100)))) self.add_condition(2, 0, 1, self.condition2) self.add_condition(2, 1, 0, self.condition2) # Robot 3 self.add_tactic( 3, GoToPositionPathfinder(self.game_state, 0, Pose(Position(2100, 0)))) self.add_tactic( 3, GoToPositionPathfinder(self.game_state, 0, Pose(Position(-2100, 0)))) self.add_condition(3, 0, 1, self.condition3) self.add_condition(3, 1, 0, self.condition3) self.add_tactic(4, Stop(self.game_state, 4)) self.add_tactic(5, Stop(self.game_state, 5))
def __init__(self, p_game_state): super().__init__(p_game_state) robot1 = 4 robot2 = 2 robot3 = 3 self.tactic_conditions = [False for i in range(PLAYER_PER_TEAM)] dist_inter_robot = 300 positions_on_xaxis = [ Pose(Position(-dist_inter_robot * 3, 0), 1.57), Pose(Position(-dist_inter_robot * 2, 0), 1.57), Pose(Position(-dist_inter_robot, 0), 1.57), Pose(Position(dist_inter_robot, 0), 1.57), Pose(Position(2 * dist_inter_robot, 0), 1.57), Pose(Position(3 * dist_inter_robot, 0), 1.57) ] shuffle(positions_on_xaxis) positions_on_yaxis = [ Pose(Position(0, -dist_inter_robot * 3), 0), Pose(Position(0, -dist_inter_robot * 2), 0), Pose(Position(0, -dist_inter_robot), 0), Pose(Position(0, dist_inter_robot), 0), Pose(Position(0, 2 * dist_inter_robot), 0), Pose(Position(0, 3 * dist_inter_robot), 0) ] shuffle(positions_on_yaxis) ''' for i in range(PLAYER_PER_TEAM): self.add_tactic(i, GoToPositionPathfinder(self.game_state, i, positions_on_xaxis[i])) self.add_tactic(i, GoToPositionPathfinder(self.game_state, i, positions_on_yaxis[i])) self.add_condition(i, 0, 1, partial(self.condition, i)) self.add_condition(i, 1, 0, partial(self.condition, i)) ''' self.add_tactic( robot1, GoToPositionPathfinder(self.game_state, robot1, positions_on_xaxis[robot1])) self.add_tactic( robot1, GoToPositionPathfinder(self.game_state, robot1, positions_on_yaxis[robot1])) self.add_condition(robot1, 0, 1, partial(self.condition, robot1)) self.add_condition(robot1, 1, 0, partial(self.condition, robot1)) self.add_tactic( robot2, GoToPositionPathfinder(self.game_state, robot2, positions_on_xaxis[robot2])) self.add_tactic( robot2, GoToPositionPathfinder(self.game_state, robot2, positions_on_yaxis[robot2])) self.add_condition(robot2, 0, 1, partial(self.condition, robot2)) self.add_condition(robot2, 1, 0, partial(self.condition, robot2)) self.add_tactic( robot3, GoToPositionPathfinder(self.game_state, robot3, positions_on_xaxis[robot3])) self.add_tactic( robot3, GoToPositionPathfinder(self.game_state, robot3, positions_on_yaxis[robot3])) self.add_condition(robot3, 0, 1, partial(self.condition, robot3)) self.add_condition(robot3, 1, 0, partial(self.condition, robot3)) for i in range(PLAYER_PER_TEAM): if not (i == robot1 or i == robot2 or i == robot3): self.add_tactic(i, Stop(self.game_state, i))