Skip to content

Commit 3efcbd1

Browse files
Fixed an issue with user input agents and games that have a state that does not accept STOP actions.
1 parent e07c94c commit 3efcbd1

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ exclude = _test\.py$
44

55
strict = false
66
disable_error_code = type-arg
7+
8+
[mypy-edq.*]
9+
ignore_missing_imports = True

pacai/agents/userinput.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ def get_action_full(self,
4848
intended_action = state.get_last_agent_action()
4949
used_user_input = False
5050

51-
# If the action is illegal, then just stop.
51+
# If the action is illegal, then just stop (if legal) or pick a random action.
5252
if (intended_action not in legal_actions):
53-
intended_action = pacai.core.action.STOP
53+
if (pacai.core.action.STOP in legal_actions):
54+
intended_action = pacai.core.action.STOP
55+
else:
56+
intended_action = self.rng.choice(legal_actions)
57+
5458
used_user_input = False
5559

5660
return pacai.core.agentaction.AgentAction(intended_action, clear_inputs = used_user_input)

pacai/ui/web.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def _handle_request(self, data_handler: typing.Callable) -> None:
192192
self.end_headers()
193193

194194
if (payload is not None):
195-
self.wfile.write(payload)
195+
self.wfile.write(payload) # type: ignore[arg-type]
196196

197197
def _route(self, path: str, params: dict[str, typing.Any]) -> RequestHandlerResult:
198198
path = path.strip()

0 commit comments

Comments
 (0)