felixvonsamson / Energetica

Energy game used as a learning tool
https://energetica.ethz.ch
Other
6 stars 1 forks source link

Energetica

Energetica is a game focused on electricity and energy management, designed to be both compelling and educational.

Try out Energetica online at http://energetica.ethz.ch.

License

Copyright (c) 2024 Felix von Samson, Maximilien Tirard, Yassir Akram.

This project is licensed under the GNU Affero General Public License (AGPL) - see the LICENSE file for details.

Technology Stack

Energetica uses Flask and Python for its backend, SQL for its database, and Jinja, JavaScript, and p5.js for its frontend.

Running a Local Instance

Make sure you have Python 3.10 or above installed.

Clone the repository:

git clone https://github.com/felixvonsamson/Energetica

Install the required dependencies using pip:

pip install -r requirements.txt

Or using conda:

conda install -c conda-forge --file requirements.txt

To launch an instance of the server, run:

python main.py

The server will be accessible at http://127.0.0.1:5001

Command line options are available to help with debugging:

python main.py --help
usage: main.py [-h] [--clock_time {60,30,20,15,12,10,6,5,4,3,2,1}] [--in_game_seconds_per_tick {3600, 1800, 1200, 900, 600, 540, 480, 420, 360, 300, 240, 180, 120,
60, 30}] [--random_seed] [--run_init_test_players] [--rm_instance] 

options:
  -h, --help            show this help message and exit
  --clock_time {60,30,20,15,12,10,6,5,4,3,2,1}
                        Clock time interval in seconds (default is 60)
  --in_game_seconds_per_tick {3600, 1800, 1200, 900, 600, 540, 480, 420, 360, 300, 240, 180, 120, 60, 30}
                        Number of in-game seconds in a game tick (default is 240)
  --random_seed         sets the random seed of the game
  --run_init_test_players
                        run the init_test_players function
  --rm_instance         remove the instance folder

Source Code Formatting and Linting

Use Ruff, Pylint and isort for Python. Use vscode's built in formatter for Javascript. Use djLint for Jinja. Use Better Jinja for code highlighting in vscode. Both specified through pyproject.toml. Use Code Spell Checker for spell checking. Keep lines to a maximum of 120 characters. For Python docstrings, fit the opening and closing triple double quotes on the same line as the docstring if it all fits in one line, otherwise keep both the opening and closing triple double quotes on their own line.