This is the second gateway of the plan (docs/project-plan.md). It brings the finished game of the base, the main of 020-snake-game (commit 1a638c9), into this repository: Snake, Food, Scoreboard, the main flow and all their tests. It does not yet compare the game with the day-21 lectures; that is MIL-003.
What is in the pull request
One commit per task, each with a Task: MIL-002#N trailer:
tests/fakes.py: the fake segment, screen and Turtle base class
snake.py and test_snake.py: Snake
food.py and test_food.py: Food(Turtle)
scoreboard.py and test_scoreboard.py: Scoreboard(Turtle)
main.py, __main__.py and test_main.py: the main flow and python -m snake_game
README.md: Status, Run and Project layout describe the adopted game
docs/sqa/reviews/rc-008-mil-002-code.md: the review of the code against QC-PY-001 (Go), and the registry's next review number
A follow-up commit resolves the pending commit link in RC-008.
Differences from the base
None in the ten adopted files: each is byte-identical to the base commit (checked with cmp), and the number of test functions is the same (91). The only new text is the README (taken from the base README's Run and Project layout sections) and the review record.
Checks run (Windows PowerShell, .venv)
pytest: 128 passed, no window opened. Each test file also passes alone, and all files pass in reverse order.
ruff check src tests, ruff format --check src tests, mypy: clean on 13 files
doxygen Doxyfile: 0 warnings
Importing snake_game.main loads neither turtle nor tkinter
Every name of objective 5 of the Business Case exists; no lecture value is a literal outside constants.py (AST search)
.env is untracked and its token values occur in no other file
The assistant also started python -m snake_game twice and closed its window, once after about 2 seconds and once after about 5 seconds: both ended with exit code 0 and an empty error output, and the window title was "My Snake Game". The game-over text was not seen. This is a smoke test, not a manual play.
MIL-002 Go/No-Go criteria
#
Criterion
Result
1
Adopted files match the base
Pass: byte-identical, no difference to list
2
All tests pass without a display
Pass: 128 passed, every test of the base is present
3
Lint, format and types are clean
Pass
4
doxygen Doxyfile builds
Pass, 0 warnings
5
The game can be played
Open: S01 plays it (see below)
6
Closing the window ends quietly
Pass for a real window closed during play and after about 5 seconds: exit code 0, empty error output. Closing after the game-over text was not observed
7
Importing the main flow needs no display
Pass
8
The assignment's names exist
Pass
9
Constants are in one place
Pass
10
The code is reviewed
Pass: RC-008 Go
11
The README matches the adopted game
Pass
12
No secret is in the change
Pass
For the reviewer
Criterion 5 is yours. Please play the game in Windows PowerShell with the .venv active (python -m snake_game): the snake moves and turns, the food is eaten, the snake grows, the score rises, and the game ends at the wall and at the tail, with the text GAME OVER and a click that closes the window. Issue #14 (verify the adopted game end to end) is left open for that and for criterion 6 after game over; close it when you have played.
RC-008 is not independent: the assistant that adopted the code also reviewed it, and S01 is both author and reviewer. It also asks whether catching Terminator and TclError to end quietly when the window is closed is acceptable.
The values of the code (food, wall, distances, text) are checked against the day-21 lectures in MIL-003, not here.
## MIL-002: Adopt the game
This is the second gateway of the plan (`docs/project-plan.md`). It brings the finished game of the base, the `main` of [020-snake-game](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/020-snake-game) (commit `1a638c9`), into this repository: `Snake`, `Food`, `Scoreboard`, the main flow and all their tests. It does not yet compare the game with the day-21 lectures; that is MIL-003.
### What is in the pull request
One commit per task, each with a `Task: MIL-002#N` trailer:
1. `tests/fakes.py`: the fake segment, screen and `Turtle` base class
2. `snake.py` and `test_snake.py`: `Snake`
3. `food.py` and `test_food.py`: `Food(Turtle)`
4. `scoreboard.py` and `test_scoreboard.py`: `Scoreboard(Turtle)`
5. `main.py`, `__main__.py` and `test_main.py`: the main flow and `python -m snake_game`
6. `README.md`: Status, Run and Project layout describe the adopted game
7. `docs/sqa/reviews/rc-008-mil-002-code.md`: the review of the code against `QC-PY-001` (`Go`), and the registry's next review number
A follow-up commit resolves the `pending` commit link in RC-008.
### Differences from the base
None in the ten adopted files: each is byte-identical to the base commit (checked with `cmp`), and the number of test functions is the same (91). The only new text is the README (taken from the base README's Run and Project layout sections) and the review record.
### Checks run (Windows PowerShell, `.venv`)
- `pytest`: 128 passed, no window opened. Each test file also passes alone, and all files pass in reverse order.
- `ruff check src tests`, `ruff format --check src tests`, `mypy`: clean on 13 files
- `doxygen Doxyfile`: 0 warnings
- Importing `snake_game.main` loads neither `turtle` nor `tkinter`
- Every name of objective 5 of the Business Case exists; no lecture value is a literal outside `constants.py` (AST search)
- `.env` is untracked and its token values occur in no other file
The assistant also started `python -m snake_game` twice and closed its window, once after about 2 seconds and once after about 5 seconds: both ended with exit code 0 and an empty error output, and the window title was "My Snake Game". The game-over text was not seen. This is a smoke test, not a manual play.
### MIL-002 Go/No-Go criteria
| # | Criterion | Result |
| --- | --- | --- |
| 1 | Adopted files match the base | Pass: byte-identical, no difference to list |
| 2 | All tests pass without a display | Pass: 128 passed, every test of the base is present |
| 3 | Lint, format and types are clean | Pass |
| 4 | `doxygen Doxyfile` builds | Pass, 0 warnings |
| 5 | The game can be played | **Open: S01 plays it** (see below) |
| 6 | Closing the window ends quietly | Pass for a real window closed during play and after about 5 seconds: exit code 0, empty error output. Closing after the game-over text was not observed |
| 7 | Importing the main flow needs no display | Pass |
| 8 | The assignment's names exist | Pass |
| 9 | Constants are in one place | Pass |
| 10 | The code is reviewed | Pass: RC-008 `Go` |
| 11 | The README matches the adopted game | Pass |
| 12 | No secret is in the change | Pass |
### For the reviewer
- **Criterion 5 is yours.** Please play the game in Windows PowerShell with the `.venv` active (`python -m snake_game`): the snake moves and turns, the food is eaten, the snake grows, the score rises, and the game ends at the wall and at the tail, with the text GAME OVER and a click that closes the window. Issue #14 (verify the adopted game end to end) is left open for that and for criterion 6 after game over; close it when you have played.
- RC-008 is not independent: the assistant that adopted the code also reviewed it, and S01 is both author and reviewer. It also asks whether catching `Terminator` and `TclError` to end quietly when the window is closed is acceptable.
- The values of the code (food, wall, distances, text) are checked against the day-21 lectures in MIL-003, not here.
Closes #8
Closes #9
Closes #10
Closes #11
Closes #12
Closes #13
Refs #14
Tirsvad
added this to the MIL-002: Adopt the game milestone 2026-10-08 12:31:51 +02:00
Copied unchanged from the base (020-snake-game, commit 1a638c9): the fake segment, the fake screen and the fake Turtle base class that record their calls, so every test runs without a display. The fake turtle module is installed with monkeypatch, so it is undone after each test.
Task: MIL-002#1
Closes#8
Copied unchanged from the base: create_snake, add_segment, extend, move, hits_wall, hits_tail, up, down, left and right, with the segments list and the head. The tail check loops over the slice segments[1:]. snake.py does not import turtle until a real segment is made.
Task: MIL-002#2
Closes#9
Copied unchanged from the base: class Food(Turtle) with refresh, and one random_coordinate function that the tests replace. MIL-003 checks the values against the day-21 lectures.
Task: MIL-002#3
Closes#10
Copied unchanged from the base: class Scoreboard(Turtle) with update_scoreboard, increase_score and game_over. MIL-003 checks the values against the day-21 lectures.
Task: MIL-002#4
Closes#11
Copied unchanged from the base: screen set-up, key bindings, the animation loop with game_is_on, the eating check, the game-over check, the wait for a click and the quiet exit when the window is closed. main imports food and scoreboard only when it runs, so importing it needs neither turtle nor tkinter.
Task: MIL-002#5
Closes#12
The Status, Run and Project layout sections now describe python -m snake_game, the keys, the food, the score and the game-over rules, taken from the base README. MIL-003 finishes the README for the whole game.
Task: MIL-002#6
Closes#13
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
MIL-002: Adopt the game
This is the second gateway of the plan (
docs/project-plan.md). It brings the finished game of the base, themainof 020-snake-game (commit1a638c9), into this repository:Snake,Food,Scoreboard, the main flow and all their tests. It does not yet compare the game with the day-21 lectures; that is MIL-003.What is in the pull request
One commit per task, each with a
Task: MIL-002#Ntrailer:tests/fakes.py: the fake segment, screen andTurtlebase classsnake.pyandtest_snake.py:Snakefood.pyandtest_food.py:Food(Turtle)scoreboard.pyandtest_scoreboard.py:Scoreboard(Turtle)main.py,__main__.pyandtest_main.py: the main flow andpython -m snake_gameREADME.md: Status, Run and Project layout describe the adopted gamedocs/sqa/reviews/rc-008-mil-002-code.md: the review of the code againstQC-PY-001(Go), and the registry's next review numberA follow-up commit resolves the
pendingcommit link in RC-008.Differences from the base
None in the ten adopted files: each is byte-identical to the base commit (checked with
cmp), and the number of test functions is the same (91). The only new text is the README (taken from the base README's Run and Project layout sections) and the review record.Checks run (Windows PowerShell,
.venv)pytest: 128 passed, no window opened. Each test file also passes alone, and all files pass in reverse order.ruff check src tests,ruff format --check src tests,mypy: clean on 13 filesdoxygen Doxyfile: 0 warningssnake_game.mainloads neitherturtlenortkinterconstants.py(AST search).envis untracked and its token values occur in no other fileThe assistant also started
python -m snake_gametwice and closed its window, once after about 2 seconds and once after about 5 seconds: both ended with exit code 0 and an empty error output, and the window title was "My Snake Game". The game-over text was not seen. This is a smoke test, not a manual play.MIL-002 Go/No-Go criteria
doxygen DoxyfilebuildsGoFor the reviewer
.venvactive (python -m snake_game): the snake moves and turns, the food is eaten, the snake grows, the score rises, and the game ends at the wall and at the tail, with the text GAME OVER and a click that closes the window. Issue #14 (verify the adopted game end to end) is left open for that and for criterion 6 after game over; close it when you have played.TerminatorandTclErrorto end quietly when the window is closed is acceptable.Closes #8
Closes #9
Closes #10
Closes #11
Closes #12
Closes #13
Refs #14