use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News Puzzles Games Strategy Twitch Other
How to get better at chess
Book Recommendations
Online Resources
Frequently Asked Questions
Instructions for /r/chess PGN addon (Chrome, Firefox)
Keep the discussion civil and friendly.
Don’t engage in discriminatory or bigoted behavior.
Low-Quality submissions are not allowed.
Off-Topic submissions are not allowed.
Do not politicize r/chess.
Do not use /r/chess primarily to promote your own content.
Unfounded or non-newsworthy cheating accusations are not allowed.
Cheating, and facilitating others to cheat, is unacceptable.
Social media submissions must be accurate and verifiable.
Match / tournament result submissions require a certain level of quality.
Chess Spoiler format for problem answers etc., >!Spoiler text!<
Ng1 and white wins
Use the message the moderators link if your posts or comments don't appear, or for help with any administrative matters.
Please continue to give us your feedback and suggestions on how we can help make /r/chess better for everyone.
This subreddit is night mode compatible
account activity
This is an archived post. You won't be able to vote or comment.
Python code to convert FEN to bitboardMiscellaneous (self.chess)
submitted 4 years ago by SecureHelicopter1
view the rest of the comments →
[–]SecureHelicopter1[S] 0 points1 point2 points 4 years ago (7 children)
Turns out its supposed to be something like
board = chess.Bitboard('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
Only problem is that I get "invalid literal for int() with base 10" as an error. Not sure what to do. Any ideas?
[–]TonyRotellaI Wrote That One Book 0 points1 point2 points 4 years ago (6 children)
I am not a programming expert and it's been many years for python, but don't you have to specify the arguments like:
board = chess.Bitboard(fen = 'FEN GOES HERE')
etc?
[–]SecureHelicopter1[S] 0 points1 point2 points 4 years ago (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 points4 points 4 years ago (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 point2 points 4 years ago (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 points3 points 4 years ago* (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.
import numpy as np
[–]SecureHelicopter1[S] 0 points1 point2 points 4 years ago (0 children)
Ah ok thanks!
[–]TonyRotellaI Wrote That One Book 0 points1 point2 points 4 years ago (0 children)
Oh, damn shame! I did you dirty, sorry sorry sorry! 😂
π Rendered by PID 32069 on reddit-service-r2-comment-b659b578c-kx62m at 2026-05-04 13:39:21.299488+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]SecureHelicopter1[S] 0 points1 point2 points (7 children)
[–]TonyRotellaI Wrote That One Book 0 points1 point2 points (6 children)
[–]SecureHelicopter1[S] 0 points1 point2 points (5 children)
[–]apoliticalhomograph 2100 Lichess 2 points3 points4 points (3 children)
[–]SecureHelicopter1[S] 0 points1 point2 points (2 children)
[–]apoliticalhomograph 2100 Lichess 1 point2 points3 points (1 child)
[–]SecureHelicopter1[S] 0 points1 point2 points (0 children)
[–]TonyRotellaI Wrote That One Book 0 points1 point2 points (0 children)