How to get a 4v4 chess board version using the python chess library

298 Views Asked by At

I am trying to figure out how to use the chess library in python to get a 4x4 board instead of an 8x8 with Rook, Queen, King, and Rook at the back and the middle rows being Pawns.

I tried setting up the board through this line but it gives an error saying that it expects 8 columns per row in position apart of fen

board = chess.Board("rqkr/pppp1Qpp/2n2n2/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4")

I just would like to get a working 4x4 board instead of 8x8.

Any help is appreciated.

1

There are 1 best solutions below

0
On

I do not think there is a possible way to do so with the python-chess library. You might have to make a new 4x4 board class with pure python.

Python chess only supports boards for registered variants.

None of the registered variants include a 4x4 board.

Also since you passed the board fen into a standard board class it threw an error since it expects the board to have 8 rows and columns.