92 questions
2
votes
0
answers
143
views
How can I make lookups in c++ as fast as possible?
I'm trying to create a chess bot. I'm using bit-boards to represent the board and pieces. I read online from several sources that using PEXT for sliding piece lookups makes your code really fast. I ...
0
votes
0
answers
76
views
Storing piece attacks for bitboards
I know that to store the knight's attacks for example I begin by initializing an array of 64 uint64s representing all the possible knight attacks and fill it up then whenever I need the move of a ...
2
votes
1
answer
119
views
How do I look for the 7shape in the game of Connect 4 using bitboards for each player?
The shape I am looking for looks like this:
I have two bitboards that represent two players in the game Connect 4. The bits that are used are bits from 0 to 48, so 49 bits in total. The ...
1
vote
0
answers
64
views
How can I create a good high probability unique uin64 hashmap key with two bitboards plus one bit that represents players turn?
I have two bitboards that represent two players in the game Connect 4. The bits that are used are bits from 0 to 48, so 49 bits in total. The representation looks like this:
6 13 20 27 34 41 48 55 ...
-1
votes
1
answer
107
views
How can I optimize this transposition table for connect 4 AI? [closed]
The transposition table uses keys from the position of player 0 and player 1 from bitboards and includes the player turn at the end, I did that to guarantee unique keys for all states. But this seems ...
1
vote
1
answer
84
views
How can I check for symmetry along the mid column in the board of Connect 4 in javascript when using bitboards?
I have the bitboard representation like this for each player:
00000000 0000000 0000001 0000010 0000100 0010001 0000101 0000000 0000001
00000000 0000000 0000000 0000001 0000011 0001110 0000010 0000000 ...
1
vote
0
answers
83
views
Pushing tiles using bitboards and bit operations
Am am currently coding up a somewhat chess-like game that includes a "pushing" mechanic. Getting an efficient algorithm for this seems to be elusive.
Here are the details. I represent an NxM ...
1
vote
1
answer
204
views
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 ...
1
vote
0
answers
151
views
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 ...
-1
votes
1
answer
230
views
Bitmaps/bitboards in Java
I'm programming a chess engine in Java and I would like to represent all pieces positions in one variable called bitmap or bitboard. In C++ I would simply use unsigned long, or so-called uint64_t. But ...
1
vote
0
answers
229
views
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 ...
0
votes
1
answer
223
views
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 ...
1
vote
1
answer
40
views
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, ...
2
votes
1
answer
257
views
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 ...
4
votes
2
answers
5k
views
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 ...
0
votes
1
answer
258
views
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 ...
0
votes
1
answer
145
views
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.
...
3
votes
1
answer
198
views
Fast way of checking for alignment of in a 6x6 bitboard
I am trying to find a quick and fast way to check for alignment of 5 bits in a 6x6 board in all directions (diagonal, horizontal, vertical). The board is represented as a bitboard as they are very ...
0
votes
2
answers
76
views
Chess Engine Wrong Number of 4 Plie Board States [closed]
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 (...
-1
votes
1
answer
142
views
Can BigIntegers be used in java to represent bitboards?
I recently started working on my school project which is writing a chinese chess game with a computer player in Java, I want to represent the board with bitboards, however since the board is 9x10, ...
1
vote
1
answer
219
views
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(?) ...
0
votes
1
answer
287
views
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 ...
1
vote
1
answer
90
views
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:
...
3
votes
1
answer
576
views
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 ...
0
votes
1
answer
172
views
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 ...
1
vote
1
answer
1k
views
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 ...
1
vote
1
answer
709
views
Bitboard JavaScript - How to identify the exact piece/position that 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 ...
-1
votes
1
answer
466
views
Modify a bit at a given position in a int from left to right:
I have been trying to come up with a funtion were given a int it would modify a bit at a given position using bitwise operations:
For example:
modify_bit(int, pos)
modify_bit(0b10000, 1) should return ...
3
votes
1
answer
6k
views
how to use bitboards in chess?
I am making a bitboard based chess engine and I would like to ask - assuming that I made a bitboard to every piece, what do I do with it? I read a little bit about some techniques like if you shift ...
1
vote
1
answer
245
views
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 ...
2
votes
1
answer
151
views
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
...
1
vote
0
answers
1k
views
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-...
2
votes
1
answer
54
views
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 ...
0
votes
1
answer
237
views
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 ...
0
votes
1
answer
236
views
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 ...
4
votes
0
answers
282
views
Python Bitboard more than 64bit using Numpy lib
i'm actually trying to create an AI that can play a board game.
My problem is that the boardgame is using a 9x9 square, so i can't use a 64bitboards like usually. Is there any way on how to use more ...
0
votes
1
answer
196
views
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 ...
3
votes
1
answer
475
views
Understanding "o^(o-2r)" formula for generating sliding piece moves using unsigned bitboards?
What I Am Trying To Do
I am trying to perform some bitwise operations to create a chess engine. To make this engine, I need to be able to generate moves for pieces, like rooks. There is a handy ...
3
votes
1
answer
2k
views
Is there a way to reverse the bit order in UInt64?
I am building a chess engine in Swift based off a tutorial written in Java. In the tutorial, Java's signed 64 bit integer long has a static method called reverse(long i) that "Returns the value ...
2
votes
0
answers
2k
views
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 ...
0
votes
1
answer
149
views
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 ...
3
votes
0
answers
376
views
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.
...
2
votes
1
answer
786
views
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 ...
1
vote
1
answer
642
views
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 ...
1
vote
0
answers
488
views
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 ...
4
votes
3
answers
880
views
Bit scan forward and reverse in numpy
I need to count the number of trailing and leading zeros in a numpy uint64 variable, so right now I'm doing it like this:
# n > 0
n = np.uint64(100)
s = np.binary_repr(n)
trail_zeros = len(s) - ...
0
votes
1
answer
244
views
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 ...
0
votes
1
answer
748
views
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()...
1
vote
2
answers
3k
views
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 ...
7
votes
4
answers
683
views
Bitboard to titboard (ternary bitboard) conversion
In many board games (like checkers, go and othello/reversi) each square can be represented by three states: white, black or empty.
8x8 boards in such game engines are usually represented as two ...