Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material value #25

Closed
FilipAndersson245 opened this issue Oct 5, 2019 · 1 comment
Closed

Material value #25

FilipAndersson245 opened this issue Oct 5, 2019 · 1 comment

Comments

@FilipAndersson245
Copy link

Hello, im trying to wrap my head how i should accuire the material for Black, Respective White using a given board?

@FilipAndersson245
Copy link
Author

I implemented how i think it should look like.
Don't know how efficient it is.

fn score_board(board: &Board, color: chess::Color) -> u16 {
    let b = board.color_combined(color).0;
    let mut sum = 0u16;

    for i in 0..64u64 {
        if b & (1 << i) != 0 {
            let a:Square = ALL_SQUARES[i as usize];
            sum += match board.piece_on(a).unwrap() {
                Piece::Pawn => {1},
                Piece::Knight => {3},
                Piece::Bishop => {3},
                Piece::Rook => {5},
                Piece::Queen => {9},
                Piece::King => {100},
            }

        }
    }
    sum
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant