Skip to content
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
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Commits on Sep 8, 2019

  1. implemented save & replay

    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
    mfekadu committed Sep 8, 2019
    Configuration menu
    Copy the full SHA
    4523b95 View commit details
    Browse the repository at this point in the history
  2. refactory replay.py

    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...
    mfekadu committed Sep 8, 2019
    Configuration menu
    Copy the full SHA
    715691d View commit details
    Browse the repository at this point in the history
  3. use list-comprehension properly in replay.py

    because removing an element from a list that you are iterating over can be weird
    mfekadu committed Sep 8, 2019
    Configuration menu
    Copy the full SHA
    589354d View commit details
    Browse the repository at this point in the history
  4. more detailed filenames

    mfekadu committed Sep 8, 2019
    Configuration menu
    Copy the full SHA
    5cbfc8b View commit details
    Browse the repository at this point in the history

Commits on Sep 9, 2019

  1. replay.py v1.0

    * 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 ...
    mfekadu committed Sep 9, 2019
    Configuration menu
    Copy the full SHA
    03bacc4 View commit details
    Browse the repository at this point in the history

Commits on Sep 10, 2019

  1. try climbing the abstraction ladder

    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. ...
    mfekadu committed Sep 10, 2019
    Configuration menu
    Copy the full SHA
    b7889fe View commit details
    Browse the repository at this point in the history

Commits on Sep 14, 2019

  1. refactor main() to slowly make it smaller

    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
    mfekadu committed Sep 14, 2019
    Configuration menu
    Copy the full SHA
    0719210 View commit details
    Browse the repository at this point in the history

Commits on Sep 16, 2019

  1. rename directory

    mfekadu committed Sep 16, 2019
    Configuration menu
    Copy the full SHA
    3edfeaf View commit details
    Browse the repository at this point in the history
  2. big refactor

    no more global variables
    keyboard interaction simplified (soon to be removed from sim.py)
    helper functions
    mfekadu committed Sep 16, 2019
    Configuration menu
    Copy the full SHA
    1718e69 View commit details
    Browse the repository at this point in the history