Lab2 3/design first - #1
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The newly added lab documentation contains multiple outdated/incorrect statements and citations that contradict the current refactored main.cpp state (plus an unfilled placeholder in the report title).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR refactors the terminal Snake game to model multiplayer via a Player aggregate (snake + score) and a players collection, and adds Lab 2_3 submission artifacts (glossary, report, smell audits, and a submission-check script).
Changes:
- Refactor game state from a single
Snake/Scoreintovector<Player>with sharedFoodspawn/consumption logic. - Update rendering and HUD to show per-player scores and distinct body glyphs, plus multiplayer control help and game-over messaging.
- Add
lab2_3/documentation (ubiquitous language + report), smell audit markdowns, and acheck-lab2_3.shstructure validator.
File summaries
| File | Description |
|---|---|
| main.cpp | Introduces Player/players model, multiplayer movement/collision/food rules, updated HUD/rendering, and updated end/reset flow. |
| lab2_3/UBIQUITOUS_LANGUAGE.md | Adds a domain glossary intended to trace terms to code and flag ambiguities/drift. |
| lab2_3/REPORT.md | Adds the Lab 2_3 write-up describing glossary edits, smell deltas, and analysis. |
| lab2_3/check-lab2_3.sh | Adds a script to verify required files/report structure and print commit/run metrics for the lab submission. |
| lab2_3/audits/main.md | Adds a smell audit snapshot for the baseline (main) state. |
| lab2_3/audits/lab1-head.md | Adds a smell audit snapshot for the Lab-1 multiplayer HEAD for comparison. |
Review details
Suppressed comments (4)
lab2_3/UBIQUITOUS_LANGUAGE.md:36
- These glossary rows reference the old single-/two-scalar implementation (
sn/sc,sn2/sc2) and cite line numbers that no longer matchmain.cppafter thePlayer/playersrefactor. Update the “In code” column to point at the currentplayers/snakeFor()/Player::scoresymbols so the glossary remains traceable.
| **Player 1** | The human steering the first **Snake**, using the arrow keys | player one, P1 | `sn` / `sc` — `main.cpp:208`, `main.cpp:316` |
| **Player 2** | The human steering the second **Snake**, using W/A/S/D | player two, P2 | `sn2` / `sc2` — `main.cpp:209`, `main.cpp:317` |
| **Score** | A **Player**'s points in the current **Game**, ten per **Food** eaten | points, count | `sc`, `sc2` — `main.cpp:207`; awarded `main.cpp:292` |
| **High Score** | The single best **Score** either **Player** has reached, persisted to file between runs | best, record, top score | `hi` — `main.cpp:207`; `snake_highscore.txt` `main.cpp:104` |
lab2_3/UBIQUITOUS_LANGUAGE.md:45
- The Speed row cites
spand its initialization at line numbers that no longer match, and it doesn’t reflect thatspis set in both the constructor andreset(). Update the citations to the currentmain.cpplocations so the glossary remains auditable.
| **Speed** | The fixed millisecond delay between **Moves**; lower is faster | delay, pace, difficulty | `sp` / `speed()` — `main.cpp:207`, `main.cpp:383`; set `main.cpp:218-221` |
lab2_3/REPORT.md:38
- This paragraph states Speed is “305ms on Windows”, but
main.cppcurrently setssp = 15on Windows andsp = 150elsewhere. Please update the values and citations so the report matches the code being submitted.
Fixed two wrong definitions: **Speed** is a fixed per-platform constant, 305ms on Windows
against 150ms on Linux (`main.cpp:218-221`), not the tunable difficulty `README.md:191`
implies; and the citation for `isSnake` was `:333` when the declaration is at `:330`.
lab2_3/REPORT.md:43
- This section claims
reset()clearsscbut notsc2, but the current implementation no longer usessc/sc2andGame::reset()respawns players (resetting all scores) viaspawnPlayers(). Either update this text to reflect the current behavior or explicitly scope it to the historical commit you’re discussing so the report doesn’t contradict the branch contents.
Added three missed ambiguities: **Game** is overloaded three ways (program, class, one
play-through); **Restart** clears `sc` but never `sc2` (`main.cpp:442`), so it means different
things to the two players; and `isHead` is one flag for both heads (`main.cpp:335`), so the
display separates the bodies as 🟢/🟡 but not the heads.
- Files reviewed: 6/6 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| static const char* BODY_GLYPH[] = { "🟢", "🟡", "🔵", "🟣" }; | ||
| static const int BODY_GLYPH_COUNT = 4; |
| The third death — a **Snake**'s **Head** entering the *other* **Snake**'s **Body** — is | ||
| implemented at `main.cpp:178` and carries a **Score** penalty, but it has no name anywhere in | ||
| the repository. See **Code drift**. |
| @@ -0,0 +1,206 @@ | |||
| # Lab 2_3 — Group A__ | |||
| | **Wall** | The boundary of the play area; a **Snake** whose **Head** crosses it dies | barrier, border, edge | *(unmodelled)* — drawn `main.cpp:321-323`, enforced `main.cpp:283` ⚠ | | ||
| | **Food** | The single item on the play area that a **Snake** eats to **Grow** and score | apple, fruit, pellet | `Food` — `main.cpp:193`; `README.md:76` | |
No description provided.