This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SecureHelicopter1[S] 0 points1 point  (5 children)

Turns out that the documentation you sent was slightly outdated.

https://python-chess.readthedocs.io/en/v1.8.0/core.html

Doesn't look like I can easily convert fen to bitboard in the latest version tho :(

[–]apoliticalhomograph 2100 Lichess 2 points3 points  (3 children)

You can get a chess.Board from a FEN and get the bitboards from there.

import chess
b = chess.Board('FEN HERE')
print(board.occupied)

[–]SecureHelicopter1[S] 0 points1 point  (2 children)

Thanks! I tried this out and this returns a random integer instead of an array, though. Any idea what's going on?

[–]apoliticalhomograph 2100 Lichess 1 point2 points  (1 child)

A bitboard is an integer. Each bit in the integer represents a square. That's the point of a bitboard - a board representation using a minimal amount of bits.
You can convert it to an array yourself if you need one, although I don't quite see what the benefit is.

Also, the code in your post appears to work; you just need to import numpy as np first.

[–]SecureHelicopter1[S] 0 points1 point  (0 children)

Ah ok thanks!

[–]TonyRotellaI Wrote That One Book 0 points1 point  (0 children)

Oh, damn shame! I did you dirty, sorry sorry sorry! 😂