Skip to content

Commit f31e271

Browse files
committed
Guard against generating illegal pawn moves
1 parent ca935bf commit f31e271

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/chess.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,7 @@ export class Chess {
15681568
let to: number
15691569
if (type === PAWN) {
15701570
if (forPiece && forPiece !== type) continue
1571+
if (rank(from) === RANK_1 || rank(from) === RANK_8) continue
15711572

15721573
// single square, non-capturing
15731574
to = from + PAWN_OFFSETS[us][0]

0 commit comments

Comments
 (0)