2 Generic matrix transformations
21 u8 dst
[static TOTAL_BOARD_SIZ
],
22 const u8 src
[static TOTAL_BOARD_SIZ
],
26 assert(rotations
< 4);
33 memcpy(dst
, src
, side_len
* side_len
);
38 for (move m
= 0; m
< TOTAL_BOARD_SIZ
; ++m
) {
39 move_to_coord(m
, &x
, &y
);
40 dst
[m
] = src
[coord_to_move(side_len
- y
, x
)];
46 for (move m
= 0; m
< TOTAL_BOARD_SIZ
; ++m
) {
47 dst
[m
] = src
[TOTAL_BOARD_SIZ
- 1 - m
];
53 for (move m
= 0; m
< TOTAL_BOARD_SIZ
; ++m
) {
54 move_to_coord(m
, &x
, &y
);
55 dst
[m
] = src
[coord_to_move(y
, side_len
- x
)];
61 Rotate contents of an out_board structure.
64 out_board
* restrict dst
,
65 const out_board
* restrict src
,
68 assert(rotations
< 4);
75 memcpy(dst
->value
, src
->value
, TOTAL_BOARD_SIZ
* sizeof(double));
76 memcpy(dst
->tested
, src
->tested
, TOTAL_BOARD_SIZ
);
79 for (move m
= 0; m
< TOTAL_BOARD_SIZ
; ++m
) {
80 move_to_coord(m
, &x
, &y
);
81 move n
= coord_to_move(BOARD_SIZ
- 1 - y
, x
);
82 dst
->value
[m
] = src
->value
[n
];
83 dst
->tested
[m
] = src
->tested
[n
];
87 for (move m
= 0; m
< TOTAL_BOARD_SIZ
; ++m
) {
88 dst
->value
[m
] = src
->value
[TOTAL_BOARD_SIZ
- 1 - m
];
89 dst
->tested
[m
] = src
->tested
[TOTAL_BOARD_SIZ
- 1 - m
];
93 for (move m
= 0; m
< TOTAL_BOARD_SIZ
; ++m
) {
94 move_to_coord(m
, &x
, &y
);
95 move n
= coord_to_move(y
, BOARD_SIZ
- 1 - x
);
96 dst
->value
[m
] = src
->value
[n
];
97 dst
->tested
[m
] = src
->tested
[n
];
101 dst
->pass
= src
->pass
;
105 Flips a square matrix.
108 u8 dst
[static TOTAL_BOARD_SIZ
],
109 const u8 src
[static TOTAL_BOARD_SIZ
],
117 for (move m
= 0; m
< TOTAL_BOARD_SIZ
; ++m
) {
118 move_to_coord(m
, &x
, &y
);
119 dst
[m
] = src
[coord_to_move(side_len
- x
, y
)];
124 Flips the board contents of an out_board structure.
127 out_board
* restrict dst
,
128 const out_board
* restrict src
133 for (move m
= 0; m
< TOTAL_BOARD_SIZ
; ++m
) {
134 move_to_coord(m
, &x
, &y
);
135 move n
= coord_to_move(BOARD_SIZ
- 1 - x
, y
);
136 dst
->value
[m
] = src
->value
[n
];
137 dst
->tested
[m
] = src
->tested
[n
];
140 dst
->pass
= src
->pass
;
145 Produces the move correspondent in the transformed matrix.
153 if (method
== NOREDUCE
|| *x
>= BOARD_SIZ
) {
158 method
= method
* -1;
169 oy
= side_len
- 1 - *x
;
172 ox
= side_len
- 1 - *x
;
173 oy
= side_len
- 1 - *y
;
176 ox
= side_len
- 1 - *y
;
180 ox
= side_len
- 1 - *x
;
185 iy
= side_len
- 1 - *x
;
187 ox
= side_len
- 1 - ix
;
191 ix
= side_len
- 1 - *x
;
192 iy
= side_len
- 1 - *y
;
194 ox
= side_len
- 1 - ix
;
198 ix
= side_len
- 1 - *y
;
201 ox
= side_len
- 1 - ix
;