Fix high roll calculation

This commit is contained in:
Trevor Slocum 2024-02-07 11:32:11 -08:00
parent 6dafbdfa2a
commit 2afd9e26ff

View file

@ -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