Closed ChameleonRed closed 7 years ago
You can use board.set_piece_at()
, board.remove_piece_at()
or directly assign the board.pawns
, ..., board.kings
, board.occupied_co[color]
, board.occupied
, board.castling_rights
bitboards. (But be sure to keep them in a consistent state). board.set_castling_fen()
might also be helpful.
Yes I know but it is not optimal way - set_piece_at is cleat but using kings or pawns, castling looks very dangerous since good practice is not change fields of class directly (but not always is good). There is not function to set en_passant or set_castling_rights (I can use board.castling rights - but it is not clear).
Better is have function set_position(position, color_to_move, castling_rights, en_passant_square, half_moves, full_moves).
position can be list of [(sqaure, piece), ...]
As I said it is not clear how to set (documentation maybe or better function) and not clear what to do with en passant, half and full moves.
Currently I am using Board(fen=fen).
Board.set_pieces()
turn
is safe to set or add setterep_square
is safe to set or add setterhalfmove_clock
and fullmove_number
are safe to set or add settersFor now I don't want to add a method that does everything at once, but I added https://python-chess.readthedocs.io/en/latest/core.html#chess.BaseBoard.set_pieces and documented how to set the other fields.
I want to init board without use of fen - how to do it?
For example by list of occupied squares, castling rights, en passant, color to move, half moves, full moves.
Currently I am constructing fen manually - can I do it much faster?