Skip to content

add basic game engine#1

Merged
RobbieKiwi merged 4 commits into
mainfrom
feature/engine
May 3, 2025
Merged

add basic game engine#1
RobbieKiwi merged 4 commits into
mainfrom
feature/engine

Conversation

@RobbieKiwi

Copy link
Copy Markdown
Owner

No description provided.

@RobbieKiwi RobbieKiwi requested a review from Copilot May 3, 2025 09:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread tests/test_models/test_game_state.py
Comment thread pyproject.toml
@@ -10,3 +15,6 @@ python = "3.12.*"
pypsa = "^0.34.1"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do we need pypsa for? and how about an optimization module such as pyomo or linopy?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These packages are just placeholders for now to get going. We can change them when we start actually using packages

Comment thread src/models/player.py
from typing import Self


class PlayerId(int):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of the PlayerId class?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RomanCantu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of questions, but everything seems okay

@RobbieKiwi RobbieKiwi merged commit d6c68fd into main May 3, 2025
1 check passed
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.

3 participants