summaryrefslogtreecommitdiff
path: root/src/engine.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine.c')
-rw-r--r--src/engine.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/engine.c b/src/engine.c
new file mode 100644
index 0000000..eec420d
--- /dev/null
+++ b/src/engine.c
@@ -0,0 +1,73 @@
+#include <stdio.h>
+#include <assert.h>
+#include "engine/bitboard.h"
+#include "engine/moves.h"
+
+void comms_main();
+int direct_run();
+
+int main(int argc, char** argv) {
+ if (argc == 1) return direct_run();
+ assert(argc == 2);
+ comms_main();
+ return 0;
+}
+
+#include "ipc.c"
+void comms_main() {
+ mqd_t tx = mq_open("/engine_to_server", O_WRONLY);
+ mqd_t rx = mq_open("/server_to_engine", O_RDONLY);
+
+ 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);
+}
+
+int direct_run() {
+ moves_t moves = moves_init();
+ position_t position = position_starting();
+
+position.bitboards[WHITE_KING] = 16ULL;
+position.bitboards[WHITE_QUEEN] = 268435456ULL;
+position.bitboards[WHITE_ROOK] = 16777344ULL;
+position.bitboards[WHITE_BISHOP] = 67108896ULL;
+position.bitboards[WHITE_KNIGHT] = 66ULL;
+position.bitboards[WHITE_PAWN] = 65280ULL;
+position.bitboards[BLACK_KING] = 1152921504606846976ULL;
+position.bitboards[BLACK_QUEEN] = 576460752303423488ULL;
+position.bitboards[BLACK_ROOK] = 9295429630892703744ULL;
+position.bitboards[BLACK_BISHOP] = 2594073385365405696ULL;
+position.bitboards[BLACK_KNIGHT] = 4611687117939015680ULL;
+position.bitboards[BLACK_PAWN] = 71776119061217280ULL;
+
+ 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);
+ return 0;
+}
+
+#include "engine/bitboard.c"
+#include "engine/moves.c"