Unity Trials
Layer Mask - Raycast
Bitboards
A bit board is a data structure designed to efficienlt encode a game board state as a set of bits.(Chess board) Instead of using a bunch of individual integers to represent the state of each board position we can use a bit.
Birboards have 3 main advantages:
We need different bit boards for different states because bitboards only can hold 0 or 1. We can hold bitboard for black cells and put 1s for them, then we can make another bitboard for whites and put 1s for white cells. If we have 2 players we will need two more boards for their states. Lets say blue and red players. If we want to check which black squares that red player uses, just make black & red bitboards. Red & blue will give empty cells. Since we represent the bitboards as 2d but actually stays as 1d in memory, we can apply some rules for finding right indexes.
index = row * width + column
number[row][column] = number[row * width + column]
For instance, if I want to set 1st row 5th column bit, actually I want to set 13th bit of bit sequence. So, to set that bit, make new bit array then left shift it by 13 so that I will have 1000000000000. Then |(or) this with actual bitboard. That will make 13th bit 1. If I want to retrieve the value of bit, do the same operations and instead of | make &. If result != 0, then that bit is 1.
About Bitboard Gameplay:
NOTES: