|
1 | 1 | from thrift.protocol import TBinaryProtocol
|
2 | 2 | from thrift.transport import TSocket, TTransport
|
3 | 3 | from soccer import Game
|
4 |
| -from soccer.ttypes import State, Empty, PlayerActions, CoachActions, TrainerActions, PlayerAction, GameModeType |
| 4 | +from soccer.ttypes import DoChangeMode, DoMovePlayer, State, Empty, PlayerActions, CoachActions, TrainerActions, PlayerAction, GameModeType |
5 | 5 | from soccer.ttypes import ServerParam, PlayerParam, PlayerType, InitMessage, RegisterRequest, RegisterResponse, AgentType
|
6 | 6 | from soccer.ttypes import HeliosChainAction, HeliosBasicMove, HeliosGoalie, HeliosSetPlay
|
7 | 7 | from soccer.ttypes import DoMoveBall, RpcVector2D, TrainerAction
|
|
13 | 13 | from threading import Semaphore
|
14 | 14 | from multiprocessing import Manager, Lock
|
15 | 15 | import logging
|
| 16 | +from pyrusgeom.vector_2d import Vector2D |
16 | 17 |
|
17 | 18 | logging.basicConfig(level=logging.DEBUG)
|
18 | 19 |
|
@@ -61,20 +62,37 @@ def GetCoachActions(self, state: State):
|
61 | 62 | def GetTrainerActions(self, state: State):
|
62 | 63 | logging.debug(f"GetTrainerActions trainer at {state.world_model.cycle}")
|
63 | 64 | actions = []
|
64 |
| - actions.append( |
65 |
| - TrainerAction( |
66 |
| - do_move_ball=DoMoveBall( |
| 65 | + if state.world_model.cycle % 100 == 99: |
| 66 | + logging.debug(f"Trainer at cycle {state.world_model.cycle}") |
| 67 | + if len(state.world_model.teammates) == 0: |
| 68 | + return TrainerActions() |
| 69 | + player = state.world_model.teammates[0] |
| 70 | + p = Vector2D(player.position.x, player.position.y) |
| 71 | + p = p + Vector2D(10, 10) |
| 72 | + actions = [ |
| 73 | + TrainerAction( |
| 74 | + do_move_ball=DoMoveBall( |
| 75 | + position=RpcVector2D( |
| 76 | + x=p.x(), |
| 77 | + y=p.y() |
| 78 | + ), |
| 79 | + velocity=RpcVector2D( |
| 80 | + x=0, |
| 81 | + y=0 |
| 82 | + ), |
| 83 | + ) |
| 84 | + ), |
| 85 | + TrainerAction(do_move_player=DoMovePlayer( |
| 86 | + our_side=True, |
| 87 | + uniform_number=player.uniform_number, |
67 | 88 | position=RpcVector2D(
|
68 |
| - x=0, |
69 |
| - y=0 |
| 89 | + x=p.x(), |
| 90 | + y=p.y() |
70 | 91 | ),
|
71 |
| - velocity=RpcVector2D( |
72 |
| - x=0, |
73 |
| - y=0 |
74 |
| - ), |
75 |
| - ) |
76 |
| - ) |
77 |
| - ) |
| 92 | + body_direction=0., |
| 93 | + )), |
| 94 | + TrainerAction(do_change_mode=DoChangeMode(game_mode_type=GameModeType.PlayOn)) |
| 95 | + ] |
78 | 96 | return TrainerActions(actions=actions)
|
79 | 97 |
|
80 | 98 | def SendServerParams(self, serverParams: ServerParam):
|
|
0 commit comments