Fix bearing off
This commit is contained in:
parent
ff05d4a1dd
commit
1945642193
1 changed files with 13 additions and 0 deletions
13
gnubg.go
13
gnubg.go
|
@ -148,8 +148,21 @@ func parseMoves(g *bgammon.Game, moves []byte) ([4][2]int8, error) {
|
|||
return [4][2]int8{}, fmt.Errorf("failed to parse gnubg moves: invalid to (%s): %s", move[:slash], moves)
|
||||
}
|
||||
|
||||
if to == bgammon.SpaceHomePlayer && bgammon.PlayerCheckers(Game.Game.Board[from], 1) == 0 {
|
||||
for space := from; space > 1; space-- {
|
||||
if bgammon.PlayerCheckers(Game.Game.Board[space], 1) != 0 {
|
||||
from = space
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for j := 0; j < count; j++ {
|
||||
m[mc][0], m[mc][1] = int8(from), int8(to)
|
||||
ok, _ := Game.AddMoves([][]int8{{int8(from), int8(to)}}, true)
|
||||
if !ok {
|
||||
return [4][2]int8{}, fmt.Errorf("failed to add local moves (%d/%d): %s", from, to, moves)
|
||||
}
|
||||
mc++
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue