-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Step 1: Implement A "Save State" Mechanism #2
Open
mfekadu
wants to merge
9
commits into
master
Choose a base branch
from
save-state
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this commit was an attempt to "just make it work" so the code is not elegant dumping the space is as simple as `pickle.dump(space)` but I cannot dump `pickle.dump([space, window, options])` TODO: explore dumping window TODO: explore dumping options The zip files are folders that contain the dumps You need to unzip the folders in order to run `./replay` replay.py is the script to do "replay" It will search for the first folder it finds in "space_dumps" directory Then it will `pickle.load` each file in that folder it found Then we need to `space.step()` to actually have each space displayed on the screen in sequential order OH BTW... sorting the files is important.... otherwise it looks weird and jumpy DUMPS_DIR added to cfg.py TODO: figure out how to also dump the cfg.py data TODO: figure out how to minimize `replay.py` because ideally replay.py can just do everything given the file & not need to perform any sort of setup * for example replay.py needs to have the collision handler functions inside otherwise an error about "missing begin_collision in __main__" will occur
minimizing replay.py code to just the essentials also include scrubbing via arrow keys * holding right scrubs forward * holding left scrubs in reverse * UP/DOWN scrub faster still TODO: * import gzip into replay.py and sim.py * sim.py should batch pickle.dump and gzip at the end * replay.py should ungzip a given dump_file and also load it up for replay * AVOID doing `import cfg` into replay.py * because cfg.py could change in the future * rather sim.py should save all of the replay values into the dump_file (save just once.... not into each dump_file... save into its own file) * Here's an IDEA: * save replay.py with each batch of dump_files.zip.... that way every dump_files.zip will have a functional replay.... and replay can just be a script that works specifically for each batch of files. Self-contained. Would be nice. Could be annoying to have to recreate the replay.py script each time... but assuming sim.py will continue to change then replay.py will likely change along with it... so maybe that's the optimal solution? hmmm...
because removing an element from a list that you are iterating over can be weird
TODO
|
* replay.py now is a command-line utility * it does argparse of the dumps_dir * replay.py is much more minimal and cool and not hard coded * replay.py now includes a “version number” `v1.0` in the filename * Also the name says ’space_and_cfg_ to let you know what to expect out of the pickle.load deleted the old incompatable pickle.dumps include just 1 zip file containing space_and_cfg pickles TODO: optimize the pickle.dump of cfg because it only needs to be done once. But for now the redundancy is fine because cfg only takes about 1KB... but 1KB * 1000 files would be 1MB... etc ...
before we had concrete position details of the yellow circle... but now we can wait helllllla long (like 30 seconds for 2000+ frames) to load and display each position of the bot over all time frames. Looks cool but it takes too long and needs too much data TODO: compress the pickle files somehow or dont save the entire space... maybe save useful statistics like "position over time" or "velocity" or "other stuff liike that" and save the functions to recreate the shapes but not the shapes themselves. And maybe dont use pymunk to replay. Maybe just plot the positions using matplotlib. ...
New Problems:
New Solutions
|
created init_food(...) has purpose statement with clear explanation of inputs no longer afraid to pass in the space object reference because now I know that's a "reference" in python and not a giant object value
no more global variables keyboard interaction simplified (soon to be removed from sim.py) helper functions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves
Step 1
of Issue #1CHANGES
pickle
file at each frame of the game¯\_(ツ)_/¯
replay.py
allows the user to replay any folder ofspace_dump_..._.pickle
files+1
in time with RIGHT-ARROW key+1
in time with RIGHT-ARROW key+10
in time with UP-ARROW key+10
in time with DOWN-ARROW keyHere is a GIF showing the replay feature: