This project is a custom pygame implementation of the old flash game Hex Empire. This game is between 4 players on a hex board that take turns moving armies around the board to capture towns and eventually your opponent's capitals.
To run this project locally:
.venv/bin/python main.py
To run in a web browser, see the Web Build section below.
- Make the options for the game editable through an interface
- Run evolutionary algorithm to determine the best values for the CPU players
- Tasks in the
plan.txtfile
Set up a Python virtual environment and install dependencies (tested on macOS with zsh):
# create venv and install
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# alternatively run the helper script
bash scripts/setup_env.sh
Notes:
- This project requires
pygame-ce,numpy, andpygbag(listed inrequirements.txt). - The
scripts/setup_env.shscript will create or reuse.venv, upgradepip, and install fromrequirements.txt.
The game can be run in a browser via pygbag, which compiles the pygame loop to WebAssembly.
First-time setup (once per machine, after the venv is created):
# Generate the HTML shell from template.tmpl — wait for "Serving python files from..." then Ctrl+C
.venv/bin/python -m pygbag --port 8000 --template template.tmpl main.py
# Build the game bundle and download the pygame-ce WASM wheel
.venv/bin/python build_web.pyAfter any code change:
.venv/bin/python build_web.py
.venv/bin/python -m http.server 8000 --directory build/webThen open http://localhost:8000 in a browser. Click the page to dismiss the start prompt; on first load the WASM runtime (~25 MB) downloads from the pygbag CDN and is cached for subsequent runs.
Controls:
Space— new gameS— toggle stepping mode (pauses before each AI move; pressRight Arrowto step,Left Arrowto undo)E— end turn (when playing as a human player)P/L— save / load a game state