Closed mlomb closed 10 months ago
Hi, I'm looking for a way to mirror boards. For example, with python-chess I can do .mirror():
.mirror()
import chess board = chess.Board(fen="6k1/pp3pp1/4b2p/4N3/2p5/2q3P1/P4PKP/3r4 w - - 0 1") print(board.mirror().fen()) # 3R4/p4pkp/2Q3p1/2P5/4n3/4B2P/PP3PP1/6K1 b - - 0 1
Which flips vertically and swaps colors.
I tried the same thing with shakmaty but only managed to flip the board, and can't find a way to swap colors:
shakmaty
let fen: Fen = "6k1/pp3pp1/4b2p/4N3/2p5/2q3P1/P4PKP/3r4 w - - 0 1" .parse() .unwrap(); let pos: Chess = fen.into_position(CastlingMode::Standard).unwrap(); let mut board = pos.board().clone(); board.flip_vertical(); println!("{}", board); // 3r4/P4PKP/2q3P1/2p5/4N3/4b2p/pp3pp1/6k1
How could I do it? Can it be added to shakmaty?
I'm looking for this because I'm working with ML and need the board to always be from the POV of white
Thanks!
Hi. Sure, added Board::swap_colors().
Board::swap_colors()
Hi, I'm looking for a way to mirror boards. For example, with python-chess I can do
.mirror()
:Which flips vertically and swaps colors.
I tried the same thing with
shakmaty
but only managed to flip the board, and can't find a way to swap colors:How could I do it? Can it be added to
shakmaty
?I'm looking for this because I'm working with ML and need the board to always be from the POV of white
Thanks!