niklasf/shakmaty

Allow Board::color_at to return empty squares colour

Closed this issue · 3 comments

It would be useful for turning a board into e.g emojis

pub fn create_emoji_board(board: Board) -> String {
    let mut board_str = String::new();

    for sq in Square::ALL {
        let piece = board.piece_at(sq);
        if let Some(piece) = piece {
			// use the piece to generate emoji
        } else {
            let col = board.color_at(sq); // If there is no piece at said square, return the
                                          // blank squares colour
        }
    }

    board_str
}

Hi. You can use sq.is_dark() or sq.is_light().

Hi. You can use sq.is_dark() or sq.is_light().

I am a stupid

Nah, this is easy to miss. Black/white are used for pieces in this lib, and dark/light used for squares.