This project is a historical simulation game engine set in 1937. It is structured as a modular Python application using a custom library for the game logic and a runner script for execution.
The project is organized into two main parts:
libs/sim1937: A standalone Python library containing the core game engine, country definitions, and game logic.- Top-level Runner: The root directory contains the
main.pyentry point and configuration to run the game using the library.
- Python: Version 3.11 or higher.
- uv: A fast Python package installer and resolver.
-
Install uv (if not already installed):
pip install uv
-
Sync Dependencies: Initialize the virtual environment and install all dependencies (including the local
sim1937library).uv sync
To enable the live dashboard feature, you need to set up Google Cloud credentials.
-
Create a Google Cloud Project:
- Go to the Google Cloud Console.
- Create a new project (e.g., "Sim1937 Game").
-
Enable APIs:
- Go to APIs & Services > Library.
- Search for and enable Google Sheets API.
- Search for and enable Google Drive API.
-
Create Service Account:
- Go to APIs & Services > Credentials.
- Click Create Credentials > Service Account.
- Give it a name (e.g., "game-bot") and click Create.
- (Optional) Grant the "Editor" role to the service account.
-
Generate Key File:
- Click on the newly created service account email.
- Go to the Keys tab.
- Click Add Key > Create new key.
- Select JSON and download the file.
-
Configure Project:
- Rename the downloaded JSON file to
credentials.json. - Move
credentials.jsonto the root directory of this project (next tomain.py).
- Rename the downloaded JSON file to
-
Share the Sheet:
- Create a new Google Sheet (or use an existing one).
- Open the
credentials.jsonfile and copy theclient_emailaddress. - In your Google Sheet, click Share and paste the service account email.
- Give it Editor access.
- Important: Update the
SHEET_NAMEinlibs/sim1937/src/sim1937/config.pyto match your Google Sheet's name exactly.
To start the game simulation, use the following command:
uv run main.py- With Sheets: If
credentials.jsonis present and configured correctly, the game will connect to Google Sheets. - Test Mode: If
credentials.jsonis missing, the game will automatically default to "TEST MODE" and run in the terminal without Sheets integration.
The project includes a test suite for the sim1937 library using pytest.
To run the tests, execute:
uv run --extra dev pytestThis command will:
- Install the development dependencies (like
pytest). - Discover and run all tests located in
libs/sim1937/tests.
If you want to modify the game logic:
- Navigate to
libs/sim1937/src/sim1937. - Edit the files (e.g.,
game_engine.py,country.py). - Since the library is installed in "editable" mode, changes will be reflected immediately when you run
main.pyor the tests.