nkarve / surge

A fast bitboard-based chess move generator in C++
MIT License
63 stars 15 forks source link

Double pawn moves are considered captures by Move.is_capture() #26

Open SloPro opened 1 year ago

SloPro commented 1 year ago
#include <iostream>
#include "position.h"
using namespace std;

int main()
{
    initialise_all_databases();
    zobrist::initialise_zobrist_keys();

    Position pos;
    Position::set(DEFAULT_FEN, pos);
    cout << pos << endl;

    MoveList<WHITE> moves(pos);
    for (const auto &m : moves)
    {
        cout << "     " << m << " iscapture: " << m.is_capture() << " flags: " << m.flags() << endl;
    }

    return 0;
}

Generates the following:

...
     f2f3 iscapture: 0 flags: 0
     g2g3 iscapture: 0 flags: 0
     h2h3 iscapture: 0 flags: 0
     a2a4 iscapture: 1 flags: 1
     b2b4 iscapture: 1 flags: 1
     c2c4 iscapture: 1 flags: 1
     d2d4 iscapture: 1 flags: 1
     e2e4 iscapture: 1 flags: 1
     f2f4 iscapture: 1 flags: 1
     g2g4 iscapture: 1 flags: 1
     h2h4 iscapture: 1 flags: 1

As you can see, move.is_capture() returns true for double pawn moves despite the flag being correctly set to MoveFlags::DOUBLE_PUSH (= 1).

Thibor commented 1 year ago

in function is_capture need change CAPTURES to CAPTURE and this will be fixed

Thibor commented 1 year ago

i found next errror in constructor Move(const std::string& move) , does not support promotion like a7a8n