Snake daily: first food depends on the previous run, so the board differs per player
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- Moins d'une heure
- Accessibilité débutants
- 84/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- typescript
- Domaine
- game-dev
Piste de recherche
Commence dans games/snake/scenes/GameScene.ts : init() (vers les lignes 105-123) réinitialise l'état propre à chaque partie, mais pas this.food, et create() (ligne 141) appelle randomFreeCell() (lignes 462-468), qui voit encore la nourriture de la partie précédente. Déclare food comme private food: Cell | undefined et vide-le dans init(). Vérifie ensuite que freeCells dans games/snake/logic.ts et le choix initialisé par graine dans shared/rng.ts se comportent comme le décrit le ticket. C'est terminé lorsque la première case de nourriture quotidienne correspond après un chargement à neuf, après PLAY AGAIN et après RESTART, que le mode normal reste inchangé et que npm test réussit.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
In Neon Snake's daily challenge, where the first food appears depends on the last food of the previous run played on the same page. The board is supposed to be the same for everyone who steers the same way, but it isn't.
Where
games/snake/scenes/GameScene.ts:105-123(init, never resetsfood)games/snake/scenes/GameScene.ts:141(create,this.food = this.randomFreeCell())games/snake/scenes/GameScene.ts:462-468(randomFreeCell)
Details
Phaser reuses the scene instance, and init() resets bonus, score, eaten and the rest, but not this.food. On the second and later runs on a page, create() calls randomFreeCell() while this.food still holds the previous run's last food cell:
private randomFreeCell(): Cell {
const taken = this.players.flatMap((p) => p.segments);
if (this.food) taken.push(this.food);
if (this.bonus) taken.push(this.bonus.cell);
const free = freeCells(taken);
return this.cellRng ? this.cellRng.pick(free) : Phaser.Utils.Array.GetRandom(free);
}
freeCells() lists cells in row-major order, so excluding one extra cell shifts every index after it. The seeded cellRng.pick(free) then lands on a different cell, and every later pick follows from that different board.
Impact
Daily scores are not comparable. A player who played a normal run, a previous daily run, or pressed RESTART before the daily gets a different food sequence from a player who opened the daily fresh. Replaying the daily on the same page is not the same board either.
Steps to reproduce
- Open
games/snake/?mode=daily, start DAILY, and note the first food cell. Then die. - Choose PLAY AGAIN.
- The first food cell is often different (whenever the previous run's last food sat before the picked index).
Suggested fix
Clear this.food in init() (declare it as private food: Cell | undefined), so the first randomFreeCell() of every run sees only the snake.
Acceptance criteria
- The first daily food cell is the same on a fresh page load and after PLAY AGAIN, RESTART or a normal run.
- Normal mode behaviour is unchanged.
Getting started
- Relevant files:
games/snake/scenes/GameScene.ts,games/snake/logic.ts(freeCells),shared/rng.ts(dailyRng) - How to run tests:
npm test - Related: #78 (Snake daily mode)
Filed by repo-audit/full-audit at de2b25b. Severity: medium. Effort: S. audit-key: bug|games/snake/scenes/GameScene.ts|randomFreeCell
- Langage dominant
- TypeScript
- Étoiles
- 3
- Forks
- 3
- Merge moyen
- 8 h 13 min
- PR mergées (30 j)
- 2
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TMHSDigital/GH-Arcade
-
ci good first issue severity: low
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
TMHSDigital/GH-Arcade#111 ·
-
bug good first issue severity: low
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
TMHSDigital/GH-Arcade#105 ·
-
bug good first issue severity: low
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
TMHSDigital/GH-Arcade#104 ·
-
Add a game speed assist settingOuverteaccessibility enhancement severity: low
Difficulté 4/5 3-5 jours Accessibilité débutants 40/100
TMHSDigital/GH-Arcade#114 ·
-
enhancement severity: low
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
TMHSDigital/GH-Arcade#113 ·
Toutes les issues de TMHSDigital/GH-Arcade
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
steelbrain/node-ssh#487 ·
-
cli: `execCargoMetadata` decodes stdout per chunk, corrupting non-ASCII paths across pipe boundariesOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulté 1/5 Moins d'une heure Accessibilité débutants 62/100
lingdojo/kana-dojo#34127 · 1 commentaire · 5 réactions ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 68/100
osmlab/name-suggestion-index#13104 ·
Les mainteneurs répondent en général sous 1 jour