Questions tagged [bitboard]

A bitboard is a data structure commonly used in computer systems that play board games.

A bitboard, often used for boardgames such as chess, checkers and othello, is a specialization of the bitset data structure, where each bit represents a game position or state, designed for optimization of speed and/or memory or disk use in mass calculations. Bits in the same bitboard relate to each other in the rules of the game often forming a game position when taken together. Other bitboards are commonly used as masks to transform or answer queries about positions. The "game" may be any game-like system where information is tightly packed in a structured form with "rules" affecting how the individual units or pieces relate.

85 questions
2
votes
1 answer

How to display a bitboard derived from binary literals?

I'm trying to print out a chess game which I am implementing using bitboards. I'm having trouble visualizing how would I go about display the 8x8 grid with the pieces for play. Here's the link to the tutorial I am following (albeit incomplete). …
Carrein
  • 3,231
  • 7
  • 36
  • 77
2
votes
1 answer

How to properly use bitboards

I'm wondering what is the correct way to implement bitboards into a chess engine. So far I did some research on the basics of chess engine programming and took some notes, mostly stuff such as minimax, alphabeta, quiescence search and advanced…
JavaIsMyBae
  • 35
  • 1
  • 6
2
votes
1 answer

Bitboard: hexadecimal to binary conversion

I am initializing bitboards for chess programming. However, when I initialize the black bitboards, the binary output is incorrect for some reason. The following is the code: #include #include #include #include…
user5482467
2
votes
4 answers

Is there a cheap way to "mirror" the bits in a byte?

When trying to test for reachability on a straight line without looping, you can use Bitboard representation. Imagine chess, a row or column of the board represented as a byte and the question if a Rook on square X can capture a target on square…
BitTickler
  • 10,905
  • 5
  • 32
  • 53
2
votes
2 answers

Rotating a bitboard

I'm working with 24-bit bitboards in Java representing a game board of the following form: 00 01 02 03 04 05 06 07 08 09 10 11 XX 12 13 14 15 16 17 18 19 20 21 22 23 Note that the board has a hole in the middle indicated by the 'XX'. I've generated…
Arthelais
  • 606
  • 1
  • 7
  • 17
2
votes
1 answer

generating bitboard masks for move

I'm trying to understand how works bitboard representation in chess programming and I can't find usefull information (or just can't translate it correctly ^^) about one detail. My question is, how to generate automaticly masks for move on every…
Puchacz
  • 1,987
  • 2
  • 24
  • 38
2
votes
4 answers

Efficient board representation for strategy board game AI

Would a bitboard representation still be as effective in a dumbed-down chess-like strategy game which has less than 64 positions or would a simpler array based mailbox implementation be more practical? Our school's AI class has an annual…
2
votes
1 answer

Can't write range based for with non-member begin and end functions

I'm writing a code that uses bitboards. since iterating on all bits of a bitboard is pretty common action, I decided to write some iterator class, and to use c++0x's range based loops. However, g++ (version 4.6.3) tell me that there is not matching…
asaelr
  • 5,438
  • 1
  • 16
  • 22
1
vote
1 answer

Strange error when bit shifting uint64_t by a uint16_t in cpp

The function below is attempting to create a bitboard with the set bit being in the Nth position, by bitshifting 0x1 N times to achieve desired result. N is being given by the 1-6th least significant bits in a uint16_t. It is then masked to isolate…
1
vote
0 answers

genrating sliding piece moves on bitboard efficiently without magic bitboard

I'm currently working to improve a chess engine in python. more specifically I'm working on the move generation of sliding pieces, like rooks and bishops. originally I used this loop function for both rook and bishop moves: def get_rook_moves(self,…
Smillyone
  • 11
  • 1
1
vote
0 answers

Generating special magic numbers

For context: https://www.chessprogramming.org/Looking_for_Magics are the magic numbers I am talking about Hey, I would like to map availabilty of king attacks to low order 8 bits. For example, king's attack's on A1 would be (B1, A2, B2). Suppose I…
user16009754
1
vote
1 answer

How does the binary representation of a C# ulong data type work?

I'm currently trying to print a ulong data type as 8x8 grid of binary bits since the ulong data type has 8 bytes - 64 bits. While trying to do so, I keep getting a bit turned on with 32-bit offset. To understand my problem, look at the…
mich abay
  • 23
  • 3
1
vote
1 answer

Unexpected bits appearing in binary conversion

I have been converting some Tic Tac Toe code to use bitboard so I can implement an AI opponent. As part of the test code I wanted to conduct a bitwise AND comparison to check if the moves are valid, then later to see available moves. However I am…
Dave022
  • 43
  • 3
1
vote
2 answers

Chess bitboard move generation

I am writing a chess engine, and I'm understanding how chess engines store game positions (in 64-bit bitboards) and how to generate moves from them. When you get your final bitboard of moves, how do you know what piece moves where? For example, take…
1
vote
1 answer

Bitboard 64-bit machine: should I use int16 or int64 for a 4x4 board?

I'm programming a 4x4 board game in C++ using bitboards in a 64-bit machine. I only need 16 bits to implement the board. Should I use: uint16_t - to reduce used space? uint64_t - if operations are(?) faster with 64-bit integers, should I use them…
André Dias
  • 103
  • 1
  • 6