domino14 / macondo

A crossword board game AI, written in Go
https://domino14.github.io/macondo
GNU General Public License v3.0
48 stars 10 forks source link

endgame crash when no plays are available #332

Closed domino14 closed 2 months ago

domino14 commented 2 months ago
macondo> load cgp 11GEAN/10HARM1/6Y2NINE2/6L3NE3/4KUE1PAD4/6MARC3V1/7JOTA1YEW/5W1IF1D2T1/4VIDS2I1COO/3BOT2AXE1O1v/L1FREE4U1O1A/ODOR3cULSHIER/2BRUNT1PE2N1I/TIS6ZA1GAE/10IT1IS GL/EQ 345/353 0 lex NWL18;

macondo> endgame
plies 4, maxtime 0, threads 10

   A B C D E F G H I J K L M N O     ->              player1       GL  345
   ------------------------------                    player2           353
 1|=     '       =       G E A N |
 2|  -       "       " H A R M   |   Bag + unseen: (2)
 3|    -       Y   ' N I N E     |
 4|'     -     L '     N E     ' |   E Q 
 5|        K U E   P A D         |
 6|  "       " M A R C       V   |
 7|    '       ' J O T A   Y E W |
 8|=     '   W   I F   D '   T = |
 9|    '   V I D S '   I   C O O |
10|  "   B O T     A X E   O " v |   Turn 0:
11|L   F R E E         U   O   A |
12|O D O R       c U L S H I E R |
13|    B R U N T   P E     N   I |
14|T I S     "       Z A   G A E |
15|=     '       =     I T   I S |
   ------------------------------

macondo> {"level":"info","time":"2024-05-28T23:45:30-04:00","message":"creating zobrist hash"}
{"level":"info","num-elems":536870912,"desired-num-elems":1050086080,"estimated-total-memory-bytes":8589934592,"mem-limit":67205509120,"reset":false,"time":"2024-05-28T23:45:30-04:00","message":"transposition-table-size"}
{"level":"info","threads":10,"time":"2024-05-28T23:45:30-04:00","message":"using-lazy-smp"}
{"level":"info","plies":2,"time":"2024-05-28T23:45:30-04:00","message":"deepening-iteratively"}
{"level":"info","α":-16,"β":0,"window":8,"spread":-15,"ply":2,"pv":"PV; val -7; 1: (Pass) (0); 2: 13L E. (7); ","time":"2024-05-28T23:45:30-04:00","message":"best-val"}
panic: runtime error: index out of range [9] with length 1

goroutine 56 [running]:
github.com/domino14/macondo/endgame/negamax.(*Solver).iterativelyDeepenLazySMP.func2.5(0x96df80?, 0x96df80?)
    github.com/domino14/macondo/endgame/negamax/solver.go:467 +0x91
lukechampine.com/frand.(*RNG).Shuffle(0xc0007a4000, 0x0?, 0xc00008dec0)
    lukechampine.com/frand@v1.4.2/frand.go:147 +0x3e
lukechampine.com/frand.Shuffle(0xa, 0xc00008dec0)
    lukechampine.com/frand@v1.4.2/frand.go:277 +0x94
github.com/domino14/macondo/endgame/negamax.(*Solver).iterativelyDeepenLazySMP.func2()
    github.com/domino14/macondo/endgame/negamax/solver.go:466 +0x63e
golang.org/x/sync/errgroup.(*Group).Go.func1()
    golang.org/x/sync@v0.6.0/errgroup/errgroup.go:78 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 31
    golang.org/x/sync@v0.6.0/errgroup/errgroup.go:75 +0x96
domino14 commented 2 months ago

this only crashes for machines that have 8 or more cores and there are few possible plays in the endgame. BestBot runs on an at most 6-core lambda so that's why we didn't see the crash there 😐