Skip to content

Action History Recording & History Playback - #1

Open
Tia-Chen wants to merge 7 commits into
mainfrom
action-recording
Open

Action History Recording & History Playback#1
Tia-Chen wants to merge 7 commits into
mainfrom
action-recording

Conversation

@Tia-Chen

@Tia-Chen Tia-Chen commented Feb 12, 2024

Copy link
Copy Markdown
Collaborator

Functionalities Developed:

  1. Record player actions when flag "--record_actions" is set when running socket_env.py. At the end of the game play, user will be prompted for a filename at the terminal. Action history will be written to that file.
  • Format of history: (see 2_agent_test_replay.txt for example)
    "agent_id Action_command action_timestamp"
    "agent_id Action_command action_timestamp"
    ...

  • HOW TO USE:
    Run: socket_env.py --record_actions [other option flags]
    Then, at the end of the game, at the prompt Please enter a filename for saving the action history., enter the filename to save to.

  1. Playback player action history (replay_agent_actions.py)
  • Takes a filename of action history and sends the actions to the game play through the socket to recreate the game play

  • HOW TO USE:
    Run replay_agent_actions.py [filename]
    This assumes that the game is already running and accepting socket connections.

Testings Done:

  1. I have tried recording actions in these forms:
  • Single player actions simulated through keyboard_input
  • Single player actions simulated through socket
  • Multi-player (2 players) actions: 1 player receives input from socket and the other from keyboard
  1. I have tried the playback using files in these forms:
  • Single player history record files
  • Multi-player (2 players) history record files

Notes:
About Future Plans:
We've briefly talked about potentially implementing the "reverse" function as a future plan. My current thought is that we need a series of "state" (or observations) that we can revert back to, and then match that state up to a place file of player actions through timestamp.
There is a save_state function currently implemented, which could be useful. Currently:

  • keyboard inputs: user has to manually save the state at instances the user finds useful.
  • socket inputs: the observations are sent back automatically to the client.
    In order to use the state as tool to revert back to previous state to reverse playback, it would require us to save the state at every player action, timestamp them, and save them to file for socket input game plays. For keyboard input game plays, we may have to put in another piece of logic to write the observations with every command as well.
    Does this sound like a reasonable plan? Each observation will be long. Will space memory be of concern?

use --record_action flag at command line to set recording on. At the end of the game, user will be prompted for a filename to save the action history to.
Player Action Recording:
- Added timestamp to record
- Added action recording to commands sent through socket as well. This adapts for multiplayer action recording/

Playback feature:
- Playback feature added (replay_agent_actions.py). The program takes a file name and sends the action history stored in the file to the game to be played back.
@Tia-Chen
Tia-Chen requested a review from mscheutz February 12, 2024 03:01
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.

1 participant