0

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.

user302543
  • 59
  • 7
Scrap
  • 1
  • 2
    `python-chess` only works with 8x8 boards. Now, your setup does have 8 rows, and it had 8 columns in every row but the first. Were you trying to fake something here? – Tim Roberts Apr 28 '21 at 18:11
  • You could, I suppose, try "rqkr4/pppp4/PPPP4/RQKR4/8/8/8/8" and just play in the upper left corner. – Tim Roberts Apr 28 '21 at 18:12
  • Why is that interesting? Aren't all the games the same? If I start c3xb2+, black has take with the queen ...b1xb2, which I can then take a3xb2+, he has to take with his king ...c1xb2, I move the queen out b4-c3+ and he's screwed. – Tim Roberts Apr 28 '21 at 18:16
  • 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. – typedecker May 05 '21 at 09:26
  • Python chess only supports boards for [registered variants](https://python-chess.readthedocs.io/en/latest/variant.html#). See list. – typedecker May 05 '21 at 09:27
  • And as per my knowledge none of the registered variants include a 4x4 board. Also since you passed the fen into a standard board class it threw an error since it expects the board to have 8 rows and columns. – typedecker May 05 '21 at 09:28

1 Answers1

0

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.

typedecker
  • 1,351
  • 2
  • 13
  • 25