From 2afd9e26ff7c89e4296de099e9a7f8e680222c2f Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Wed, 7 Feb 2024 11:32:11 -0800 Subject: [PATCH] Fix high roll calculation --- board.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/board.go b/board.go index 620f166..b29845c 100644 --- a/board.go +++ b/board.go @@ -517,15 +517,21 @@ func (b Board) Available(player int8) ([][4][2]int8, []Board) { } if !moved { var highestRoll int8 - var highestIndex int - for i, move := range newMoves { + for _, move := range newMoves { roll := b.spaceDiff(player, move[0][0], move[0][1]) if roll > highestRoll { highestRoll = roll - highestIndex = i } } - newMoves = [][4][2]int8{newMoves[highestIndex]} + var highRollMoves [][4][2]int8 + for _, move := range newMoves { + roll := b.spaceDiff(player, move[0][0], move[0][1]) + if roll != highestRoll { + continue + } + highRollMoves = append(highRollMoves, move) + } + newMoves = highRollMoves } } return newMoves, boards