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
0
votes
1 answer

Assign TicTacToe player position to a bitboard representation

I have 2 separate boards for 2 players: X and O. Now I'd like to make sure if an entered position (int x, int y) is valid but I've got no idea of how should I convert it to bitboard representation and compare it with given board states and it's…
0
votes
1 answer

c++ Conversion from String to Bitboard and Back Optimization

I am working with a game state which is received as a string and needs to be converted into a BitBoard. I believe I have a function that accomplishes that now, but want to know how I can optimize it for faster execution? I originally started with a…
Baiano42
  • 33
  • 6
0
votes
1 answer

How to generate this preinitialized array for magic bitboards?

I am currently trying to make my chess engine faster, and am looking at implementing magic bitboards for my sliding piece attack generation. I am using a bitboard representation of the chessboard with the a1 square being the furthest right bit, and…
user14717506
0
votes
1 answer

Chess BitBoards in kotlin. Which datatype?

i think this question has not been asked yet. Thing is, in chess we use bitboards to speed move-generation-cycles up by representing a position by a bit=1 and other by a bit=0. In chess we have 8*8 positions. In combination with modern cpus its…
Plagueis
  • 173
  • 1
  • 3
  • 12
0
votes
1 answer

Finding the binary composition of a binary number

Very new to C#, so this could be a silly question. I am working with alot of UInt64's. These are expressed as hex right? If we look at its binary representation, can we return such an array that if we apply the 'or' operation to, we will arrive back…
0
votes
1 answer

Are overflow operators less efficient than performing operations that don't result in overflows?

What I Am Doing: I am writing a chess engine in Swift. One of the most important parts of writing a strong chess engine is the ability to generate as many possible future board positions in as little time possible. The more positions your engine can…
David Chopin
  • 2,780
  • 2
  • 19
  • 40
0
votes
1 answer

Java connect four bit wise functions and bit board errors

Essentially im trying to create a connect four Ai and i came across an article which uses bit boards to optimize making moves and checking for wins. Essentially i took a few methods from a git hub readme which are supposed to make a move and undo a…
0
votes
1 answer

Problem with moving bits in the bitboard to the left in Python

I am programming a chess ai. I ran into a problem when I want to move the bits from the king_span to the left. When I move the bits up to 45 places, it works fine. If I want to move them more than 45 places, the outputed bitboard is the same, as if…
0
votes
1 answer

Generating bitboard with diagonal moves for the bishop not working

I am in the middle of programming a chess ai. I have run into a problem when trying to calculate all possible diagonal moves for the bishop. I think the problem lies within the function: reverse_bits(). I don't think I handle negative binary numbers…
0
votes
1 answer

Bitboard: counting elements with neighbours

In order to represent the state of a 2D board game, I am using bitboards with 16bits unsigned integers. The state is encoded with 1 for piece presence and 0 else. What is the bitboard way to count the number of pieces having at least one adjacent…
Loheek
  • 1,865
  • 17
  • 28
0
votes
1 answer

Converting C++ function to C#

I'm trying to convert c++ funtion to c#, but I'm failing for the second straight hour. Need help:/ The function is taken from this question bool haswon(unsigned __int64 newboard) { unsigned __int64 y = newboard & (newboard >> 6); if (y & (y…
Louisa Bickley
  • 297
  • 5
  • 17
0
votes
2 answers

Sliding Piece Generation in Chess Engine

So I've been having some trouble wrapping my head around an issue. I'm currently writing a bitboard based chess engine in Java (its been a ride figuring everything out). So far all of the pawn/king/knight moves work as expected and without…
thePanthurr
  • 104
  • 1
  • 9
0
votes
1 answer

Swift 3 uint64 overflows when trying to assign 64 bit integer

I'm trying to implement bitboards in Swift and am trying to store a 64bit integer into a UInt64 and get an overflow error. var white_queen_bb:uint64 = 0001000000000000000000000000000000000000000000000000000000000000 as UInt64; Integer Literal…
Eridanis
  • 410
  • 1
  • 6
  • 19
0
votes
2 answers

Given a chess app built with magic bitboard how do I check for checkmate?

OK, I have this chess app built with bitboard and I want to check if a given move put the opponent pieces in checkmate. Verifying a check situation is easy. You build the bitmask of the enemy pieces' attack and you AND that with the bitmask of the…
Duck
  • 34,902
  • 47
  • 248
  • 470
0
votes
2 answers

Flip one dimensional array board representation about the x axis

I am in the midst of programming a chess AI, and have encountered an issue with my implementation of piece-square tables. Since I only want to have one piece-square table per side, I need a function to flip the one-dimensional array that holds the…
nman
  • 57
  • 1
  • 8