fix board.go bugs
This commit is contained in:
parent
7f22b4f4b3
commit
73aa9f8854
4
board.go
4
board.go
|
|
@ -71,7 +71,7 @@ func (b *Board) isSquareAttacked(pos Position, byColor int) bool {
|
||||||
r, c := pos.Row, pos.Col
|
r, c := pos.Row, pos.Col
|
||||||
pawnDir := 1
|
pawnDir := 1
|
||||||
if byColor == Black {
|
if byColor == Black {
|
||||||
pawnDir = -1
|
pawnDir = 1
|
||||||
}
|
}
|
||||||
for dc := -1; dc <= 1; dc += 2 {
|
for dc := -1; dc <= 1; dc += 2 {
|
||||||
nr, nc := r-pawnDir, c+dc
|
nr, nc := r-pawnDir, c+dc
|
||||||
|
|
@ -199,7 +199,7 @@ func (b *Board) pawnMoves(from Position, color int) []Move {
|
||||||
r, c := from.Row, from.Col
|
r, c := from.Row, from.Col
|
||||||
dir := 1
|
dir := 1
|
||||||
if color == Black {
|
if color == Black {
|
||||||
dir = -1
|
dir = 1
|
||||||
}
|
}
|
||||||
nr := r + dir
|
nr := r + dir
|
||||||
if b.inBounds(nr, c) && b.Grid[nr][c].Piece == Empty {
|
if b.inBounds(nr, c) && b.Grid[nr][c].Piece == Empty {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue