Skip to content

Commit 2f992f5

Browse files
committed
update GetBestPlannerAction
1 parent db3236c commit 2f992f5

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.venv/
22
scripts/proxy
3-
scripts/rcssserver
3+
scripts/rcssserver
4+
logs/

server.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def GetPlayerActions(self, state: pb2.State):
5353
simple_shoot=True,
5454
simple_dribble=True,
5555
cross=True,
56-
server_side_decision=True
56+
server_side_decision=False
5757
)))
5858
actions.append(pb2.PlayerAction(helios_shoot=pb2.HeliosShoot()))
5959
else:
@@ -64,13 +64,15 @@ def GetPlayerActions(self, state: pb2.State):
6464
self.logger.debug(f"Actions: {actions}")
6565
return pb2.PlayerActions(actions=actions)
6666

67-
def GetBestPlannerAction(self, pairs: pb2.BestPlannerActionRequest):
68-
self.logger.debug(f"GetBestPlannerAction cycle:{pairs.state.world_model.cycle} pairs:{len(pairs.pairs)} unum:{pairs.register_response.uniform_number}")
69-
pairs_list: list[int, pb2.RpcActionState] = [(k, v) for k, v in pairs.pairs.items()]
70-
pairs_list.sort(key=lambda x: x[0])
71-
best_action = max(pairs_list, key=lambda x: -1000 if x[1].action.parent_index != -1 else x[1].predict_state.ball_position.x)
72-
self.logger.debug(f"Best action: {best_action[0]} {best_action[1].action.description} to {best_action[1].action.target_unum} in ({round(best_action[1].action.target_point.x, 2)},{round(best_action[1].action.target_point.y, 2)}) e:{round(best_action[1].evaluation,2)}")
73-
res = pb2.BestPlannerActionResponse(index=best_action[0])
67+
def GetBestPlannerAction(self, request: pb2.BestPlannerActionRequest) -> int:
68+
self.logger.debug(f"GetBestPlannerAction cycle:{request.state.world_model.cycle} pairs:{len(request.pairs)} unum:{request.state.register_response.uniform_number}")
69+
best_index = max(request.pairs.items(), key=lambda x: x[1].evaluation)[0]
70+
best_action = request.pairs[best_index].action
71+
72+
while best_action.parent_index and best_action.parent_index > 0:
73+
best_action = request.pairs[best_action.parent_index].action
74+
75+
res = pb2.BestPlannerActionResponse(index=best_action.index)
7476
return res
7577

7678
def GetCoachActions(self, state: pb2.State):

service_pb2.py

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service_pb2_grpc.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
import service_pb2 as service__pb2
77

8-
GRPC_GENERATED_VERSION = '1.67.0'
8+
GRPC_GENERATED_VERSION = '1.65.4'
99
GRPC_VERSION = grpc.__version__
10+
EXPECTED_ERROR_RELEASE = '1.66.0'
11+
SCHEDULED_RELEASE_DATE = 'August 6, 2024'
1012
_version_not_supported = False
1113

1214
try:
@@ -16,12 +18,15 @@
1618
_version_not_supported = True
1719

1820
if _version_not_supported:
19-
raise RuntimeError(
21+
warnings.warn(
2022
f'The grpc package installed is at version {GRPC_VERSION},'
2123
+ f' but the generated code in service_pb2_grpc.py depends on'
2224
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
2325
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
2426
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
27+
+ f' This warning will become an error in {EXPECTED_ERROR_RELEASE},'
28+
+ f' scheduled for release on {SCHEDULED_RELEASE_DATE}.',
29+
RuntimeWarning
2530
)
2631

2732

0 commit comments

Comments
 (0)