Questions tagged [bitboard]

For questions about bitboards and using bitboards

A bitboard is basically a 64 bit field which contains the map of squares to which a particular piece can move. They can be manipulated using very fast bitmap operations and 64 bits maps on to the address field of most modern processors. This makes their use great for improving engine performance.

This tag is for questions about bitboards and how and when to use them.

28 questions
12
votes
2 answers

How to represent chess state with a bitboard

I'm interested in programming a chess engine and using bitboards to represent the state of the game. I know there are a few open source chess engines that use bitboards, but its not so easy to look at the code and understand what is going on. I'm…
axiopisty
  • 393
  • 1
  • 3
  • 9
9
votes
1 answer

Find magic numbers for bitboards

I am writing a C++ chess engine and I am looking for magic numbers for Little-Endian Rank-File Mapping bitboards to generate moves for sliding pieces. The rival chess website gives magic numbers but not for the same board mapping. The chess…
Romain
  • 667
  • 8
  • 15
7
votes
3 answers

Representing Moves found via BitBoards, applying them, and removing them

I understand how to find all valid moves for all pieces on the board. For example I know that a certain knight can hit all of the 1's in this board 01000000 00100000 N0000000 00100000 01000000 00000000 00000000 00000000 How do I store these as…
AndrewGrant
  • 449
  • 3
  • 9
5
votes
1 answer

Are these magics wrong?

I am working on my chess engine and wanted to finally implement magic bitboards to get a huge increase in performance. Basically I was writing a method to check if a number can be used as a magic for a given attack mask. I took a look at this table:…
Finn Eggers
  • 340
  • 2
  • 9
5
votes
2 answers

Chess Engine: Generate a Bitboard of Pinned Pieces

I'm currently working on a chess engine and have a pseudo-legal move generator working. I'm looking for a way to efficiently generate a bitboard of pinned pieces, so I could skip them when generating legal moves. How would one go about doing this,…
Ori Yonay
  • 121
  • 4
5
votes
3 answers

What's the right approach of storing moves generated using bitboards?

I am building a chess engine from scratch using bitboards and, so far I am able to generate pawns moves. But, I am stuck on what should I do after finding all possible moves for pawns. Right now the current function is generating QUIETS moves…
Carlos
  • 171
  • 1
  • 8
4
votes
1 answer

How do Chess Bitboards generate individual moves?

If I have a pawn bitboard like this, for example, 00000000 00000000 00000000 00000000 00001000 00000001 11110110 00000000 generating all of the, say, legal capture moves to the right will perform a north-east shift on the bitboard, like…
AAce3
  • 388
  • 1
  • 5
4
votes
1 answer

Move generation for sliding pieces and Hyperbola Quintessence

I'm working on a bitboard-based chess engine at the moment and I have managed to generate pseudo-legal moves for knights, kings and pawns. However, I'm still trying to wrap my head around sliding pieces (bishops, rooks, queens). I have come across…
ZED
  • 103
  • 4
4
votes
1 answer

How do I complete this implementation of magic bitboards?

I'm currently coding a chess engine in C++, and have run into a bit of trouble with my magic bitboard implementation. So far, I have a function that calculates blockerBoards (all the possible pieces that can block the rook or the bishop). From…
gcahilly
  • 43
  • 4
4
votes
2 answers

Quickly converting board to bitboard representation using python-chess library

I would like to convert a given chess board into its bitboard representation, but my implementation is rather slow. Here is what I'm doing (using the python-chess package): board = chess.Board('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0…
Arman
  • 171
  • 1
  • 5
4
votes
2 answers

Building a chess using magic bitboard... how do I know if the movement is valid

OK I have read a lot of things on the web most of them using Java that doesn't have unsigned int. I am working on Objective-C that has unsigned int. Lets consider the following scenario. The board is like this: A1 is on the lower left and is the…
Duck
  • 161
  • 1
  • 5
3
votes
1 answer

How do I apply moves (bitboard) and continue searching? My current attempt is throwing a strange error!

Explanation I have a list of all possible current moves in a position. At each node, I want to then generate all possible moves and continue. The problem is that my code is modifying the list of moves in the node above. At least I think this is the…
3
votes
1 answer

Magic Bitboards, Feeding in Randoms - Why have to find magic instead of just loading from disk?

I read about Looking for Magics for Magic Bitboard, they mentioned the method "Feeding in Randoms". As I understand, this method works like this: label RETRY; magic = random();//trial for (all cases of current square: from first case to last…
123iamking
  • 181
  • 2
2
votes
2 answers

Why consider all possible combinations of empty/occupied square a sliding piece can move to in attack table generation?

When generating attack tables for a rook, why do we consider all 2^(number of set bits on the mask) potential configurations of empty or occupied squares along the ranks and files where a rook can move? Specifically, why are nonsensical…
Gabriel
  • 21
  • 1
2
votes
2 answers

Border pieces in Magic Bitboards

I've been trying to understand magic bitboards, but everywhere I've read failed to explain how edge pieces are handled. The pieces at the borders are ignored to save space. So for a bishop at D3, the move mask would…
foderking
  • 23
  • 3
1
2