Skip to content

Resolve #12: Game environment should make consistent use of PlayerAction enum - #13

Open
thowell332 wants to merge 2 commits into
mscheutz:mainfrom
thowell332:issue-12/consistent-use-of-player-action-enum
Open

Resolve #12: Game environment should make consistent use of PlayerAction enum#13
thowell332 wants to merge 2 commits into
mscheutz:mainfrom
thowell332:issue-12/consistent-use-of-player-action-enum

Conversation

@thowell332

@thowell332 thowell332 commented Jan 24, 2025

Copy link
Copy Markdown
Contributor

Resolves #12

Description of Changes:

  • To enforce consistent action names throughout the game environment, two discrepancies needed to be resolved: TOGGLE vs. TOGGLE_CART and SELECT vs. PICKUP . Since TOGGLE_CART is already in use throughout the codebase by several agents, and is the action name that is currently supported by socket_env.py, I chose to continue using this name. Since the SELECT and PICKUP actions do not appear to be in use by any agents, I chose to use the PICKUP action name to be more consistent with the internal function names in the game environment.
  • I updated socket_env.py to use the common representation of player actions defined in enums/player_action.py. I removed the ACTION_COMMANDS list defined in socket_env.py and added a helper classmethod get_names to PlayerAction to return an equivalent list.

Risks:

  • Renaming SELECT to PICKUP is a breaking change, since it changes the interface to the game environment, so any agents that are currently using the SELECT action will need to be updated to use PICKUP instead.

Notes:

  • This pull request does not make any changes to the existing agent code in astar_path_planner_*.py or socket_agent*.py. These agents only expose a subset of the available player actions defined in PlayerAction (namely, they exclude SELECT and/or RESET). If this is not a requirement, then the agent code could also be updated to use the PlayerAction enum directly.

- Rename TOGGLE to TOGGLE_CART and rename SELECT to PICKUP to make the PlayerAction enum consistent with the accepted action strings and the README
- Python enums values can already be accessed using their string representation,
so there is no need to maintain an explicit mapping
- Rather than maintain a separate list of action commands, socket_env.py
should use the PlayerAction enum
- The get_names method is for convenience when looking up an enum name
@thowell332
thowell332 force-pushed the issue-12/consistent-use-of-player-action-enum branch from 6fc607f to b14554e Compare January 25, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Game environment should make consistent use of PlayerAction enum

1 participant