Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
thrw21
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
4 ms
·
1.
▲
by
thrw21
3y ago
What do you think the average would be? No idea, I don't know what kind data OP stores (mostly few pieces? or lots of pieces? etc). You can probably tailor your format if you have more insights. But no matter what, you can alwa
2.
▲
by
thrw21
3y ago
My objective was to reduce average size, the example calculation I made is the max size
3.
▲
by
thrw21
3y ago
After some more thinking and feedback: 2 bits per square 00 empty 01 white pawn 10 black pawn 11 other piece =128 bits 4 bit index of white king on board (one of the others) 4 bit index of black king for each "other pi
4.
▲
by
thrw21
3y ago
And the full game history back to the most recent capture for draw by repetition. Ouch, I will leave this as an exercise to reader
5.
▲
by
thrw21
3y ago
https://news.ycombinator.com/item?id=39066345 You could probably modify this solution, I am already using 3 bits for piece type 0-3 rook queen bishop knight 4 Non-moved king (can castle) 5 moved king 6 pawn that moved 2 squ
6.
▲
by
thrw21
3y ago
I remembered current turn later but I could not think of your 2nd and 3rd point, you are right I guess you can't just take a look at board to see current game state, I was too focused on what game looks like while there are additional
7.
▲
by
thrw21
3y ago
But probably there can be a middle grounds. 1 bit for each square represent there is a piece on that pos so 64 bits then for each side, 4 bits to represent number of pieces and 3 bits for each piece to represent their type At max 64 + 2x(4
8.
▲
by
thrw21
3y ago
248 is max in my case (actually later I noticed I could shave another 4 bits), if there are less pieces, there will be less data But probably with encoding your solution would be better
9.
▲
by
thrw21
3y ago
Number of chess pieces are dynamic so you wouldn't know if white pieces are over and next piece is black king (kings don't have a type bits) But now I think about it, instead of a separator I could simple use 4 bits to represent
10.
▲
by
thrw21
3y ago
Bishops can only be in one of 32 spots but you need to know which one (ordering?). I was thinking of that but piece type is already 2 bits for 4 piece types so you can't have unique color bishop types without adding additional
11.
▲
by
thrw21
3y ago
They are dead and the piece that got promoted is just another regular piece
12.
▲
by
thrw21
3y ago
Here is how I would it Board is 8x8, which is 6 bits. 4 piece type (rook, queen, knight, bishop. I will represent others (king and pawn) in a special way) is 2 bits. So 8 bits in total per piece I would not use a bit to represent piece colo