add basic game engine#1
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a basic game engine along with supporting models, serialization tools, and tests.
- Added tests for GameState serialization
- Introduced utility modules for serialization and type definitions
- Created new models (Player, GameState, Event) and the Engine class for handling game events
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_models/test_game_state.py | Added tests to ensure GameState objects can be serialized and deserialized |
| src/tools/typing.py | Defined generic type variables for internal use |
| src/tools/serialization.py | Introduced serialization utilities and a Serializable protocol |
| src/models/player.py | Created Player and PlayerId classes with simple dict conversion |
| src/models/game_state.py | Implemented GameState and Phase classes with serialization support |
| src/models/event.py | Added a base Event abstract class |
| src/engine/engine.py | Defined the Engine class with a stub for event handling |
| pyproject.toml | Updated project configuration for Python 3.12 and formatter dependencies |
| .github/workflows/python-app.yml | Configured GitHub Actions workflow for testing and linting with Python 3.12 |
| @@ -10,3 +15,6 @@ python = "3.12.*" | |||
| pypsa = "^0.34.1" | |||
There was a problem hiding this comment.
what do we need pypsa for? and how about an optimization module such as pyomo or linopy?
There was a problem hiding this comment.
These packages are just placeholders for now to get going. We can change them when we start actually using packages
| from typing import Self | ||
|
|
||
|
|
||
| class PlayerId(int): |
There was a problem hiding this comment.
what is the purpose of the PlayerId class?
There was a problem hiding this comment.
The player id is a concept that we will use a lot in the project so by wrapping it in a class and giving it a name it will be easy to know exactly what we are referring to.
Sometimes types allow you to describe the meaning of things directly for example:
bids: dict[PlayerId, Bid]
Vs
bids: dict[int, Bid] # keys are player IDs
Also if you accidentally pass some other integer or id the type checker will complain
Also if we ever decide to change the player id to be uuid or str or something we would only have to change it in one place
RomanCantu
left a comment
There was a problem hiding this comment.
I left a couple of questions, but everything seems okay
No description provided.