Maze example is subtly broken
- Lingua principale
- Haskell
- Stelle
- 1.3k
- Fork
- 201
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Esegui il programma di maze condiviso e la versione riscritta collegata, quindi esamina la logica di `containsDoor` e le alternative `works`/`dont` mostrate nell’issue. Determina perché il maze può lasciare il giocatore davanti a una porta apparente, correggi il comportamento e verifica che il maze possa essere completato nelle varie riproduzioni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- haskell
- Ambito
- game-dev
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100