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
3
votes
0 answers

How to list all possible moves in connect four game

I am making an AI following this article. The basic idea is using bitboards to make a extremely fast protocol for making modifications to the board and permutating through possible game outcomes. But the article is written in python and I had…
3
votes
1 answer

Chessprogramming: how to get a single move out of a bitboard attack-mask most efficently

How can I get efficiently a single move out of an attack mask, that looks like this: ....1... 1...1... .1..1..1 ..1.1.1. ...111.. 11111111 ..1.11.. .1..1.1. for a queen. What I've done in the past, is to get the square-indices of every single…
Darius Duesentrieb
  • 837
  • 10
  • 20
3
votes
2 answers

Recognising a chess piece with bitboards

When the chessboard is stored in a variety of bitboards, how do modern chess engines recognise what type/side piece is situated on a particular cell? I'm having problems with this, since to find out what type/side piece a particular bit is, I have…
Shreyas
  • 667
  • 2
  • 7
  • 20
3
votes
2 answers

Generating individual moves from a bitboard of moves

In my chess engine, that uses bitboards for representing the board's state, generates a chunk of pseudo-legal moves in one go, a bitboard being the result. For example: Pawns: A little bitboard magic later: The bitboard at the end is simply a…
Shreyas
  • 667
  • 2
  • 7
  • 20
3
votes
4 answers

Bitboard representation for nine men morris game

I'm writing a Nine Men's Morris game in Java and have already the implemented the game rules and an AI using negamax. However, the game is based on arrays and move generation takes quite some time when the AI is thinking (starting from a ply of…
Ivan-Mark Debono
  • 15,500
  • 29
  • 132
  • 263
3
votes
2 answers

Chess Board representation - Engine

I'm working on my own chess engine in C#. Actually I'm searching bugs on my move generator, but I realized that my actual chess system is too slow (even 21 minutes on perft(6)). Here is my Github repository. I'm using a simple hierarchy for pieces…
Crybot
  • 107
  • 3
  • 8
3
votes
2 answers

Ray attacks on a bitboard

I'm trying to calculate ray attacks given the index of a 64-bit Long bitboard representation: (defn se [board index] "Produces a ray attack from the indexed bit in the south-east direction" (reduce bit-or (for [bit (rest (range index 0…
DanS
  • 17,550
  • 9
  • 53
  • 47
2
votes
1 answer

how are edge square attacks handled

I've been trying to understand magic bitboards for attack generation in chess engines. I think I roughly understand them, but one thing everyone fails to explain properly is how to handle blockers with edge squares For example, this stackoverflow…
foderking
  • 43
  • 6
2
votes
1 answer

In chess engines where bitboards are used, how are the edges detected?

For example, all white pawns' attacks are either generated by shifting 7 or 9 bits to the left (or right, I could be mistaken, but I think it's easy to get the gist). So the white pawn bitboard that looks like…
felipebubu
  • 131
  • 7
2
votes
1 answer

is there a better way to write this code in Python ? (transforming UCI-move into bitboard, chess)

I want to transform a UCI-move into bitboard. for example a2a3 -> 32768, 8388608 I need to assign [7,6,...,0] to [a,b,...,h] so that for each letter i have the assigned number(n) to calculate 2^n which i can then left shift by the value in uci[1] or…
Jay Osayi
  • 21
  • 1
2
votes
1 answer

values of protected arrays on superclass get changed unexpectedly

I'm coding a chess engine using bitboards and I wanna make an extensible API for the bitboards initializer, that would allow me to add more variants like chess960 in future. So i came up with the following abstract superclass, which gives an uniform…
big
  • 73
  • 1
  • 9
2
votes
0 answers

Generating moves in Othello with bitboards

I have made two very similar Othello AIs. In the first one, the board is represented as an array of length 100 (10x10) where the 8x8 board is represented in the "middle" of the array and the rest of the array is buffer spaces around the edge (index…
Varun Vejalla
  • 183
  • 1
  • 8
2
votes
1 answer

Computationally feasible way of finding diagonals in a bitboard

I am struggling to find an efficient way of calculating a 64-bit representation of a square's diagonals. The game in question is a board game called Othello or Reversi. I am currently working on a method to determine the stability of a piece. A…
Imak
  • 79
  • 6
2
votes
1 answer

How to rotate a centered hexagonal bitboard?

Consider the following centered hexagonal bitboard representation (padding is in boldface): 56 55 49 54 48 42 53 47 41 35 52 46 40 34 28 45 39 33…
Aadit M Shah
  • 72,912
  • 30
  • 168
  • 299
2
votes
1 answer

Bitboard algorithms for board sizes greater than 64?

I know the Magic BitBoard technique is useful for modern games that are on a n 8x8 grid because you it aligns perfectly with a single 64-bit integer, but is the idea extensible to board sizes greater than 64 squares? Some games like Shogi have…
swigganicks
  • 1,109
  • 2
  • 14
  • 28