From e816a9d881f5cb3bc38e6d65e2b9d2bf4764513b Mon Sep 17 00:00:00 2001 From: Mariano Gappa Date: Tue, 7 Jan 2020 11:21:21 +1300 Subject: [PATCH] Fixes bug with Pawn threat detection. --- api/chess.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/chess.go b/api/chess.go index a03472d..2372843 100644 --- a/api/chess.go +++ b/api/chess.go @@ -479,9 +479,9 @@ func (g game) xyThreatenedBy(sq xy, owner color, checkAllThreats bool) []piece { } // Pawns - pawnXYs := []xy{sq.add(xy{-1, -1}), sq.add(xy{1, -1})} + pawnXYs := []xy{sq.add(xy{-1, 1}), sq.add(xy{1, 1})} if owner == colorWhite { - pawnXYs = []xy{sq.add(xy{-1, 1}), sq.add(xy{1, 1})} + pawnXYs = []xy{sq.add(xy{-1, -1}), sq.add(xy{1, -1})} } if piece, ok := g.pieces[opponent][pawnXYs[0]]; ok && piece.pieceType == piecePawn { pieces = append(pieces, piece)