Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ func standardMoves(pos *Position, first bool) []Move {
if (p == WhitePawn && Square(s2).Rank() == Rank8) || (p == BlackPawn && Square(s2).Rank() == Rank1) {
for _, pt := range promoPieceTypes {
m.promo = pt
m.tags = 0 // Reset tags every promo piece type

addTags(&m, pos)
if !m.HasTag(inCheck) {
// Copy the valid move to the array
Expand Down
20 changes: 20 additions & 0 deletions game_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ import (
"time"
)

func TestPromo_Knight_Check(t *testing.T) {
fenStr := "k7/4P3/8/8/8/8/8/K7 w - - 0 1"
fen, err := FEN(fenStr)
if err != nil {
t.Fatal(err)
}
g := NewGame(fen)

knightPromoMove := g.ValidMoves()[6]

if knightPromoMove.Promo() != Knight {
t.Fatal("this promo move should be Knight")
}

if knightPromoMove.HasTag(Check) {
t.Fatal("knight promo move should not have check")
}
println(validMoves)
}

func TestCheckmate(t *testing.T) {
fenStr := "rn1qkbnr/pbpp1ppp/1p6/4p3/2B1P3/5Q2/PPPP1PPP/RNB1K1NR w KQkq - 0 1"
fen, err := FEN(fenStr)
Expand Down
Loading