diff options
Diffstat (limited to 'src/engine.c')
| -rw-r--r-- | src/engine.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/engine.c b/src/engine.c index eec420d..9c848dd 100644 --- a/src/engine.c +++ b/src/engine.c @@ -13,6 +13,14 @@ int main(int argc, char** argv) { return 0; } +struct sqrstr { + char data[2]; +}; +struct sqrstr sqr_to_str(int i) { + assert(i < 64); + return (struct sqrstr) { .data = {(i / 10) + '0', (i % 10) + '0' } }; +} + #include "ipc.c" void comms_main() { mqd_t tx = mq_open("/engine_to_server", O_WRONLY); @@ -21,22 +29,21 @@ void comms_main() { moves_t moves = moves_init(); position_t position = position_starting(); - send_queue(tx, "hello"); - send_queue(tx, "hello2"); - // send_queue(tx, "hello"); - - // moves_t moves = moves_init(); - // position_t position = position_starting(); - // // get_queen_moves(&moves, position); - // - // bitboard_t b = 0; - // - // for (int i = 0; i < moves.length; i++) { - // b |= (bitboard_t)1 << moves.moves[i].to; - // printf("%d %d | ", (moves.moves[i].from), (moves.moves[i].to)); - // } - // - // print_bitboard(b); + get_moves(&moves, position); + char buf[128]; + for (int i = 0; i <= moves.length / 32; i++) { + for (int ii = 0; ii < 32; ii++) { + if (moves.length <= 4 * i + ii) continue; + // printf("%d\n", 4 * i + ii); + struct sqrstr from_str = sqr_to_str(moves.moves[4 * i + ii].from); + struct sqrstr to_str = sqr_to_str(moves.moves[4 * i + ii].to); + buf[4 * ii + 0] = from_str.data[0]; + buf[4 * ii + 1] = from_str.data[1]; + buf[4 * ii + 2] = to_str.data[0]; + buf[4 * ii + 3] = to_str.data[1]; + } + send_queue(tx, buf, sizeof(buf)); + } } int direct_run() { |
