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
1
vote
1 answer

Unexpected output from adding bits to integer (cpp)

Problem Hello, this is my first stack overflow question. I'm using Bit-boards to represent board states in my chess engine. Currently I have a bit-board class like so: class Bitboard { public: uint64_t Board = 0ULL; void…
Oxyn
  • 17
  • 5
1
vote
1 answer

Bitboard Javascript - How to identify the exactly piece/position is attacking the king

I don't have too much knowledge about bitboards and bit operations and I got some examples of bitboard chess engines from Github. And I like to know if anyone can help me with a problem. How can I identify the exact piece that is attacking the…
JRamos29
  • 880
  • 7
  • 20
1
vote
1 answer

Stockfish 12 source code: Templates replacing function parameters

Since Stockfish is the highest rated chess engine, and it's known to be quite CPU-effiecient I decided to open its source code and try to understand and see how it works. I came across this snippet of code, simply shifts a bitboard to a certain…
user14248283
1
vote
0 answers

Fastest way to iterate over bits

I have been working on a chess engine for a while and its fairly strong (about 2700 CCRL) and was wondering the following thing: most top-level chess engines use bitboards. they are basically just 64-bit numbers which represent some binary data…
Finn Eggers
  • 857
  • 8
  • 21
1
vote
1 answer

9x9 bitboard implementation

I want to implement a 9x9 board game similar to chess, that has only rook-like moving pieces. Performance is crucial since I want to develope an AI also. I read articles about bitboards, an efficient way to represent the game engine. There are…
1
vote
0 answers

Why is this classless, 32-bit bitboard implementation of checkers slower than this 'naive' implementation using numpy arrays?

I am writing a reinforcement learning checkers engine, and I've reached a performance roadblock. The network is capable of learning quickly on my machine, but my game/mcts implementation is so slow that it takes hours for the network to play a few…
basket
  • 181
  • 6
1
vote
2 answers

How to print out bitboards correctly in Python

I want to program a chess engine using bitboards. Because I am not very familiar with bitboards I am trying to figure out first how to use them. I wrote a small function which should print the bitboard. That's where I stumbled upon a problem. My…
1
vote
1 answer

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
  • 34,902
  • 47
  • 248
  • 470
1
vote
1 answer

BitBoard for Checkers in C#

I have studied bitboard but have failed to find an example on what the bitboard coding would look like in c#. If someone would be so kind to illustrate how a checkers board (8x8) would be programmed with a 32-bit. I know there are 64 squares, but…
Tennant125
  • 33
  • 4
1
vote
1 answer

Fastest bitboard transposition (5x5)

For a puzzle-solver I'm writing, I'm looking for the fastest algorithm (minimal number of bit operations) to transpose a 5x5 bitboard with 2 bits per square in the puzzle, so: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23…
Arthelais
  • 606
  • 1
  • 7
  • 17
1
vote
2 answers

How can i use a unsigned 64 bits variables in Bits Operations in Clojure?

I have the following code: (defn BitScanReverse [^Long bit-board] (loop [value bit-board r 0] (cond (> value 0x00000000FFFFFFFF) (recur (unsigned-bit-shift-right value 32) (+ r 32)) (> value 0x000000000000FFFF) (recur…
1
vote
2 answers

Bitboard with connect 5 game?

I need your help to know if it's possible to use a bitboard for a connect 5 game. Because I saw a lot of examples for connect 4 games but nothing if the board is very large such as 15x15 or 19x19. I don't understand how can I represent the board…
Marc Lamberti
  • 763
  • 2
  • 9
  • 24
0
votes
1 answer

Rotate and reflect a 5x5 bitboard

I am trying to find a fast way to rotate and reflect a 5x5 board to store it in a transposition table. The board is represented as a bitboard as they are very fast. The bitboard is represented like this: 20 21 22 23 24 15 16 17 18 19 10 11 12 13…
0
votes
1 answer

How to increase total positions considered for a chess engine

I'm writing a chess engine in Java and using bitboards to represent the board (12 64-bit numbers). The size of an instance of this class(its retained size) is 152Bytes according to IntelliJ debugger. When trying to see a few moves a head, for each…
Kaleab_G
  • 3
  • 1
0
votes
2 answers

Chess Engine Wrong Number of 4 Plie Board States

I'm writing a chess engine, and am trying to make it as fast as possible, so I'm using bitboards to represent each type of piece. I was printing out the number of different board states at each plie (Plie = 1 person moving) and on plie 4 it gets the…
user14872384