Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0f6d9ff
:memo: Add instructions to set virtual environment, activate, install…
DanielAtCosmicDNA Jul 5, 2025
1865c58
:art: Organise code into src folder, sort the following warning: User…
DanielAtCosmicDNA Jul 5, 2025
9d9fd91
:alembic: Test with lightning.
DanielAtCosmicDNA Jul 5, 2025
a8cfb2f
:alembic: test with exponential decay.
DanielAtCosmicDNA Jul 6, 2025
e4083e8
:alembic: Test with gymnasium.
DanielAtCosmicDNA Jul 7, 2025
b8a5893
:alembic: Test with SnakeGameAI deriving from superclass SnakeGame.
DanielAtCosmicDNA Jul 9, 2025
50260b0
:alembic: use human render mode as default to allow better training o…
DanielAtCosmicDNA Jul 9, 2025
d763ddc
:alembic: Test with Dueling QNet.
DanielAtCosmicDNA Jul 9, 2025
7c3599d
:alembic: Test pyproject setup.
DanielAtCosmicDNA Aug 23, 2025
c19eccf
:art: Improve code organisation.
DanielAtCosmicDNA Aug 23, 2025
0fff18b
:heavy_plus_sign: Fast training render mode does not instantiate a py…
DanielAtCosmicDNA Aug 23, 2025
b4c1e63
:art: Organise code.
DanielAtCosmicDNA Aug 23, 2025
5a57c9e
:shirt: Format code.
DanielAtCosmicDNA Aug 23, 2025
94316c6
:fire: Remove unnecessary code.
DanielAtCosmicDNA Aug 23, 2025
66828d7
:construction: Improve Direction class to provide opposite attribute.
DanielAtCosmicDNA Aug 24, 2025
60b18e9
:construction: Improve direction class to compute cw and ccw directions.
DanielAtCosmicDNA Aug 24, 2025
d84894b
:tada: Add delimiter for training and playing. Process chart in anoth…
DanielAtCosmicDNA Aug 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.venv/
__pycache__/
.vscode/
logs/
src/snake_ai_pytorch.egg-info/
.pytest_cache/
model/
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.20.0
hooks:
- id: pyupgrade

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: ^src/pattern_identifier\.egg-info/
- id: end-of-file-fixer
exclude: ^src/pattern_identifier\.egg-info/
- id: check-yaml

- repo: https://github.com/PyCQA/bandit
rev: "1.8.3"
hooks:
- id: bandit
args: ["--exclude", ".tox,.eggs,tests"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.13" # Use the latest version
hooks:
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix"]
- id: ruff-format
# args: ["--check"] # Use --check in CI if you only want to verify


# - repo: local
# hooks:
# - id: pytest-check
# name: pytest-check
# entry: pytest
# language: system
# pass_filenames: false
# always_run: true
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,36 @@ You can find all tutorials on my channel: [Playlist](https://www.youtube.com/pla
- Part 2: Learn how to setup the environment and implement the Snake game.
- Part 3: Implement the agent that controls the game.
- Part 4: Implement the neural network to predict the moves and train it.

## How to install

```bash
# Create virtual environment
python -m venv .venv

# Activate virtual environment
source ./.venv/bin/activate

# Install dependencies
pip install -e .
```

## Evaluating the Neural Network

### 1. Running the training

```bash
python src/snake_ai_pytorch/controllers/train.py
```

### 2. Seeing the trained agent play

```bash
python src/snake_ai_pytorch/controllers/enjoy.py
```

> ## To play yourself

```bash
python src/snake_ai_pytorch/controllers/play.py
```
147 changes: 0 additions & 147 deletions agent.py

This file was deleted.

154 changes: 0 additions & 154 deletions game.py

This file was deleted.

Loading