Skip to content

Commit 051a683

Browse files
committed
update based on new proto
1 parent 9a3d410 commit 051a683

12 files changed

Lines changed: 614 additions & 310 deletions

‎grpc-server.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@ class Game(pb2_grpc.GameServicer):
1313
def __init__(self):
1414
self.agent = SamplePlayerAgent()
1515

16-
def GetActions(self, request:pb2.State, context):
16+
def GetPlayerActions(self, request:pb2.State, context):
1717
# with lock:
1818
actions = self.agent.get_actions(request.world_model)
1919
return actions
2020

21+
def GetCoachActions(self, request, context):
22+
actions = pb2.CoachActions()
23+
actions.actions.append(pb2.CoachAction(change_player_types=pb2.ChangePlayerType()))
24+
actions.actions.append(pb2.CoachAction(do_helios_say_player_types=pb2.DoHeliosSayPlayerTypes()))
25+
actions.actions.append(pb2.CoachAction(do_helios_substitute=pb2.DoHeliosSubstitute()))
26+
return actions
27+
28+
def GetTrainerActions(self, request, context):
29+
actions = pb2.TrainerActions()
30+
actions.actions.append(pb2.TrainerAction(do_move_ball=pb2.DoMoveBall(pb2.Vector2D(x=0, y=0))))
31+
return actions
32+
2133
def SendServerParams(self, request: pb2.ServerParam, context):
2234
self.agent.set_params(request)
2335
return pb2.Empty()

‎protos/service.proto‎

Lines changed: 118 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,21 @@ message WorldModel {
244244
}
245245

246246
message State {
247-
WorldModel world_model = 1;
248-
WorldModel full_world_model = 2;
247+
AgentType agent_type = 1;
248+
WorldModel world_model = 2;
249+
WorldModel full_world_model = 3;
250+
251+
}
252+
253+
enum AgentType {
254+
PlayerT = 0;
255+
CoachT = 1;
256+
TrainerT = 2;
249257
}
250258

251259
message InitMessage {
252-
bool debug_mode = 1;
260+
AgentType agent_type = 1;
261+
bool debug_mode = 2;
253262
}
254263

255264
message Dash {
@@ -748,7 +757,7 @@ message HeliosPenalty {}
748757

749758
message HeliosCommunicaion {}
750759

751-
message Action {
760+
message PlayerAction {
752761
oneof action {
753762
Dash dash = 1;
754763
Turn turn = 2;
@@ -817,12 +826,75 @@ message Action {
817826
}
818827
}
819828

820-
message Actions {
821-
repeated Action actions = 1;
829+
message PlayerActions {
830+
repeated PlayerAction actions = 1;
831+
}
832+
833+
message ChangePlayerType {
834+
int32 uniform_number = 1;
835+
int32 type = 2;
836+
}
837+
838+
message DoHeliosSubstitute {}
839+
840+
message DoHeliosSayPlayerTypes {}
841+
842+
message CoachAction {
843+
oneof action {
844+
ChangePlayerType change_player_types = 1;
845+
DoHeliosSubstitute do_helios_substitute = 2;
846+
DoHeliosSayPlayerTypes do_helios_say_player_types = 3;
847+
}
848+
}
849+
850+
message CoachActions {
851+
repeated CoachAction actions = 1;
852+
}
853+
854+
message DoKickOff {}
855+
856+
message DoMoveBall {
857+
Vector2D position = 1;
858+
Vector2D velocity = 2;
859+
}
860+
861+
message DoMovePlayer {
862+
bool our_side = 1;
863+
int32 uniform_number = 2;
864+
Vector2D position = 3;
865+
float body_direction = 4;
866+
}
867+
868+
message DoRecover {}
869+
870+
message DoChangeMode {
871+
GameModeType game_mode_type = 1;
872+
Side side = 2; //some of the game mode need to know the side
873+
}
874+
875+
message DoChangePlayerType {
876+
bool our_side = 1;
877+
int32 uniform_number = 2;
878+
int32 type = 3;
879+
}
880+
881+
message TrainerAction {
882+
oneof action {
883+
DoKickOff do_kick_off = 1;
884+
DoMoveBall do_move_ball = 2;
885+
DoMovePlayer do_move_player = 3;
886+
DoRecover do_recover = 4;
887+
DoChangeMode do_change_mode = 5;
888+
DoChangePlayerType do_change_player_type = 6;
889+
}
890+
}
891+
892+
message TrainerActions {
893+
repeated TrainerAction actions = 1;
822894
}
823895

824896
message ServerParam {
825-
float goal_width = 1;
897+
AgentType agent_type = 1;
826898
float inertia_moment = 2;
827899
float player_size = 3;
828900
float player_decay = 4;
@@ -1043,43 +1115,46 @@ message ServerParam {
10431115
float their_penalty_area_line_x = 219;
10441116
float penalty_area_half_width = 220;
10451117
float penalty_area_length = 221;
1118+
float goal_width = 222;
10461119
}
10471120

10481121
message PlayerParam {
1049-
int32 player_types = 1;
1050-
int32 subs_max = 2;
1051-
int32 pt_max = 3;
1052-
bool allow_mult_default_type = 4;
1053-
float player_speed_max_delta_min = 5;
1054-
float player_speed_max_delta_max = 6;
1055-
float stamina_inc_max_delta_factor = 7;
1056-
float player_decay_delta_min = 8;
1057-
float player_decay_delta_max = 9;
1058-
float inertia_moment_delta_factor = 10;
1059-
float dash_power_rate_delta_min = 11;
1060-
float dash_power_rate_delta_max = 12;
1061-
float player_size_delta_factor = 13;
1062-
float kickable_margin_delta_min = 14;
1063-
float kickable_margin_delta_max = 15;
1064-
float kick_rand_delta_factor = 16;
1065-
float extra_stamina_delta_min = 17;
1066-
float extra_stamina_delta_max = 18;
1067-
float effort_max_delta_factor = 19;
1068-
float effort_min_delta_factor = 20;
1069-
int32 random_seed = 21;
1070-
float new_dash_power_rate_delta_min = 22;
1071-
float new_dash_power_rate_delta_max = 23;
1072-
float new_stamina_inc_max_delta_factor = 24;
1073-
float kick_power_rate_delta_min = 25;
1074-
float kick_power_rate_delta_max = 26;
1075-
float foul_detect_probability_delta_factor = 27;
1076-
float catchable_area_l_stretch_min = 28;
1077-
float catchable_area_l_stretch_max = 29;
1122+
AgentType agent_type = 1;
1123+
int32 player_types = 2;
1124+
int32 subs_max = 3;
1125+
int32 pt_max = 4;
1126+
bool allow_mult_default_type = 5;
1127+
float player_speed_max_delta_min = 6;
1128+
float player_speed_max_delta_max = 7;
1129+
float stamina_inc_max_delta_factor = 8;
1130+
float player_decay_delta_min = 9;
1131+
float player_decay_delta_max = 10;
1132+
float inertia_moment_delta_factor = 11;
1133+
float dash_power_rate_delta_min = 12;
1134+
float dash_power_rate_delta_max = 13;
1135+
float player_size_delta_factor = 14;
1136+
float kickable_margin_delta_min = 15;
1137+
float kickable_margin_delta_max = 16;
1138+
float kick_rand_delta_factor = 17;
1139+
float extra_stamina_delta_min = 18;
1140+
float extra_stamina_delta_max = 19;
1141+
float effort_max_delta_factor = 20;
1142+
float effort_min_delta_factor = 21;
1143+
int32 random_seed = 22;
1144+
float new_dash_power_rate_delta_min = 23;
1145+
float new_dash_power_rate_delta_max = 24;
1146+
float new_stamina_inc_max_delta_factor = 25;
1147+
float kick_power_rate_delta_min = 26;
1148+
float kick_power_rate_delta_max = 27;
1149+
float foul_detect_probability_delta_factor = 28;
1150+
float catchable_area_l_stretch_min = 29;
1151+
float catchable_area_l_stretch_max = 30;
1152+
10781153
}
10791154

10801155
message PlayerType {
1081-
int32 id = 1;
1082-
float player_speed_max = 2;
1156+
AgentType agent_type = 1;
1157+
int32 id = 2;
10831158
float stamina_inc_max = 3;
10841159
float player_decay = 4;
10851160
float inertia_moment = 5;
@@ -1111,15 +1186,18 @@ message PlayerType {
11111186
float player_speed_max2 = 31;
11121187
float real_speed_max2 = 32;
11131188
int32 cycles_to_reach_max_speed = 33;
1189+
float player_speed_max = 34;
11141190
}
11151191

11161192
message Empty {
11171193
}
11181194

11191195
service Game {
1120-
rpc GetActions(State) returns (Actions) {}
1196+
rpc GetPlayerActions(State) returns (PlayerActions) {}
1197+
rpc GetCoachActions(State) returns (CoachActions) {}
1198+
rpc GetTrainerActions(State) returns (TrainerActions) {}
11211199
rpc SendInitMessage(InitMessage) returns (Empty) {}
11221200
rpc SendServerParams(ServerParam) returns (Empty) {}
11231201
rpc SendPlayerParams(PlayerParam) returns (Empty) {}
1124-
rpc SendPlayerType(PlayerType) returns (Empty) {}
1202+
rpc SendPlayerType(PlayerType) returns (Empty) {} //should be PlayerTypes
11251203
}

‎service_pb2.py‎

Lines changed: 247 additions & 219 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)