Skip to content

Gamms Game Record: Hot fix for v1#37

Merged
bridgesign merged 39 commits intomainfrom
24-glir-gamms-game-record
Feb 18, 2025
Merged

Gamms Game Record: Hot fix for v1#37
bridgesign merged 39 commits intomainfrom
24-glir-gamms-game-record

Conversation

@bridgesign
Copy link
Copy Markdown
Collaborator

@bridgesign bridgesign commented Feb 18, 2025

Quick PR for merging recording functionality of agents for Gamms v0.1

The API stability is not guaranteed and as such subject to change.

The example has been modified to show how recording and replaying works.

Quick API reference:

Context has a property called record referring to the recorder. Below is the API definition for recorder:

class Recorder:
    def record(self) -> bool:
        """
        Boolean to inform whether game is being recorded or not and ctx is alive
        """
        pass
   
    def start(self, path: str) -> None:
        """
        Start recording to the path. Raise error if file already exists
        """
        pass

    def stop(self, path: str) -> None:
        """
        Stop recording to the path and close the file handler.
        """
        pass

    def pause(self) -> None:
        """
        Pause the recording process. `self.record()` should return false if paused.  If not started or stopped, give warning.
        """
        pass

    def play(self) -> None:
        """
        Resume recording if paused. If not started or stopped, give warning.
        """
        pass

    def replay(self, path: str) -> Iterator:
        """
        Checks validity of the file and output an iterator.
        """
        pass

    def time(self) -> int64:
        """
        Return record time if replaying else return the Nanosecond time on user clock
        """
        pass

    def write(self, opCode, data) -> None:
        """
        Write to record buffer if recording. If not recording raise error as it should not happen.
        """
        pass

The replay iterator yields a record of the format {"timestamp": Int64, "opCode": opCode, "data": Optional[JsonType]}

The Opcodes are defined at gamms.typing.opcodes for reference.

Other details:

  • A requirement for py-ubjson is added for recording serialization. This is unlikely to change for some time.
  • Documentation is deferred as it is likely that API might change
  • No forward compatibility guarantees

@bridgesign bridgesign linked an issue Feb 18, 2025 that may be closed by this pull request
@bridgesign bridgesign merged commit f1fc9ff into main Feb 18, 2025
bridgesign added a commit that referenced this pull request Mar 2, 2025
* Merge updates into main (#31)

* docs

* Copy comments from main. Remove IVis duplication

* Created basic API docs

* created start.md

* Added getting started

* rearrange start

* identation and numbering

* Some cleaning

* link change

* latlon to utm (#22)

* Testing if PR will be updated on this request

* Fixed folder upload

* Removed incorrect file upload

* Removed incorrect file upload

* Node id draw and node-edge color config with sim time control (#30)

---------

Co-authored-by: Jai Malegaonkar <jai.malegaonkar@gmail.com>
Co-authored-by: minoumao <142881432+minoumao@users.noreply.github.com>

* Fix crash when running no visual (#32)

* Fix crash when using no visual engine

* Fix description in abstract visual engine

* document cleaned for merge (#34)

* document cleaned for merge

* Correction in mkdocs.yml

---------

Co-authored-by: bridgesign <eyeoeternity@gmail.com>

* Override mkdocs as its behind

* Update index.md

Override

* Create strategy.md

Override issues because of improper rebasing

* Gamms Game Record: Hot fix for v1 (#37)

* docs

* Copy comments from main. Remove IVis duplication

* Created basic API docs

* created start.md

* Added getting started

* rearrange start

* identation and numbering

* Some cleaning

* link change

* latlon to utm (#22)

* recorder abstraction and implementation , not in context yet

* modified typing init and context abstract class for recorder

* modified agent_engine and class for record object

* fixes to agent_engine.py

* added property decorator

* added correct op code to write in agent_engine

* added recording to sensor_engine

* added data as method

* spacing

* replay

* current version for Rohan

* noop addded to agent_engine.py

* Modified recording for buffered io

* Add ctx reference to switch

* replay edited along with switch case

* some fixes in code

* changed op to OpCodes

* bye

* Recording only current implemented opcodes. Sidestep sensor nonexistence. Add debt

* Quick change to agent visual init for replay. Should have proper fix with artists

* checked/fixed some errors and fixed valid step

* Pickle to ubjson

* Convert opcode to int

* Opcode to int covert

* Termination condition correction

* Context recorder stopping criteria correction

---------

Co-authored-by: Jai Malegaonkar <jai.malegaonkar@gmail.com>

* Remove graph file

* range sensor

* fix

* created arc sensor and range sensor and test cases

* combine map range and arc sensor into one, rewrote test cases

* orientation code

* updated angent sensor for fov

* tests and added sensortypes

* made changes as per PR review for private type and data; degree -> radians

* Small changes in type access and interface details

---------

Co-authored-by: Jai Malegaonkar <jai.malegaonkar@gmail.com>
Co-authored-by: minoumao <142881432+minoumao@users.noreply.github.com>
Co-authored-by: Brian <35553805+Brian-Jiang@users.noreply.github.com>
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.

GLIR: Gamms Game Record

2 participants