I am insanely impressed by the json stuff I am fooling around with.
Only had to write 3 jsonStringify
functions for my outlandish packed unions.
Two questions:
-
How can I get the (Move)
@FieldParentPtr
of the belowinfo
field? -
I wrote my functions as
pub fn jsonStringify(self: XXX, jws: *std.json.Stringify)
Wouldn’t that not be more clear thanpub fn jsonStringify(self: XXX, jws: anytype)
?
const Move = packed struct(u16) {
from: u6,
to: u6,
movetype: u2,
info: u2, // this one!
}
Here my chessboard
{
"layout": {
"start_files": [
0,
7,
4
],
"king_start_squares": [
"e1",
"e8"
],
"rook_start_squares": [
[
"h1",
"a1"
],
[
"h8",
"a8"
]
],
"castling_between_bitboards": [
[
96,
14
],
[
6917529027641081856,
1008806316530991104
]
],
"castling_king_paths": [
[
96,
12
],
[
6917529027641081856,
864691128455135232
]
],
"castling_masks": [
2,
0,
0,
0,
3,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
8,
0,
0,
0,
12,
0,
0,
4
]
},
"board": [
"no_piece",
"no_piece",
"no_piece",
"w_rook",
"w_rook",
"no_piece",
"no_piece",
"w_king",
"no_piece",
"w_pawn",
"w_pawn",
"no_piece",
"no_piece",
"no_piece",
"w_pawn",
"no_piece",
"w_pawn",
"w_bishop",
"w_knight",
"no_piece",
"no_piece",
"w_pawn",
"no_piece",
"w_pawn",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"b_queen",
"w_queen",
"no_piece",
"b_knight",
"no_piece",
"b_rook",
"b_pawn",
"b_pawn",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"b_pawn",
"b_king",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"b_pawn",
"b_rook",
"no_piece",
"b_bishop",
"no_piece",
"no_piece",
"no_piece",
"no_piece",
"no_piece"
],
"bb_by_type": [
396531910721357464,
36102464308594176,
137439215616,
288230376151842816,
72058143793741848,
51539607552,
140737488355456
],
"bb_by_color": [
34370700952,
396531876350656512
],
"values": [
3314,
3114
],
"materials": [
7452,
7200
],
"to_move": "black",
"ply": 1,
"game_ply": 47,
"is_960": false,
"state": {
"rule50": 0,
"ep_square": "a1",
"castling_rights": 0,
"last_move": {
"from": "e5",
"to": "d5",
"type": "normal",
"info": 0
},
"moved_piece": "w_queen",
"captured_piece": "b_pawn",
"key": 11146136902440991946,
"checkers": 0,
"checkmask": 0,
"pins_diagonal": 0,
"pins_orthogonal": 0,
"pins": 0,
"prev": {
"rule50": 3,
"ep_square": "a1",
"castling_rights": 0,
"last_move": {
"from": "a1",
"to": "a1",
"type": "normal",
"info": 0
},
"moved_piece": "no_piece",
"captured_piece": "no_piece",
"key": 7209347259727975727,
"checkers": 0,
"checkmask": 0,
"pins_diagonal": 0,
"pins_orthogonal": 551911718912,
"pins": 551911718912,
"prev": null
}
}
}