Maze example is subtly broken
- Vorherrschende Sprache
- Haskell
- Sterne
- 1.3k
- Forks
- 201
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
**Shared Program**: https://code.world/#PFzfkNOVOL_C9ow2vC4A52Q
**Description**
Walking a few steps in the maze eventually gets one stuck at an apparent door. I didn't bother to figure out a good seed for repro, but I never was able to finish the maze with the original code.
The bug is apparently in `containsDoor`, though it's so simple it's very hard to imagine how it can be broken. I started rewriting it and the first change was to make it use an explicit fold https://code.world/#PugJuhO_2ascCpmZGqmOe1Q:
```haskell
containsDoor :: ([Door], Door) -> Truth
containsDoor(ds, d) = foldl(\(x,d')->x || dont(d', d), False, ds)
works((a,b), (c,d)) = ((a == c) && (b == d)) || ((a == d) && (b == c))
dont(a,b) = a == b || a == reverseDoor(b)
```
Now, switching `containsDoor` between `works` and `dont` toggles the bug. I don't understand how this can be.
Beitragsleitfaden
Rechercherichtung
Führe das gemeinsame Maze-Programm und die verlinkte neu geschriebene Version aus und untersuche anschließend die `containsDoor`-Logik sowie die im Issue gezeigten Alternativen `works`/`dont`. Ermittle, warum das Maze den Spieler an einer scheinbaren Tür zurücklassen kann, korrigiere das Verhalten und überprüfe, dass das Maze in den verschiedenen Reproduktionen abgeschlossen werden kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- haskell
- Bereich
- game-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100