summaryrefslogtreecommitdiff
path: root/include/ipc.h
blob: 90a2bcce30d9e0816623c3b5363c07532ac5a2a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef IPC_H
#define IPC_H

// NOT TRUE IPC: I REALISED I AM STUPID AND COULD HAVE JUST USED THREADS

#include <sys/mman.h>
#include <stdlib.h>

#include "fen.h"
#include "uci/state.h"

typedef struct {
  struct uci_move *moves;
  int count;
  int capacity;
} comm_moves;

struct engine_message {
  int id;

  int ready;

  int depth;
  int seldepth;
  int multipv;
  int score_cp;
  int nodes;
  int nps;
  int hashfull;
  int tbhits;
  int time;

  int mate;
  bool node_limit;
  comm_moves pv;

  struct uci_move best_move;
  struct uci_move ponder;

  struct engine_message *next;
};

typedef struct {
  struct engine_message **data;
  int count;
} engine_messages;

enum { MESSAGE_FILLED, MESSAGE_READ, MESSAGE_PROCESSED };
typedef struct {
  engine_messages *engine_messages;
  uci_state state;
  int uci_state_initialized;
  int uci_message_ready;
  struct fen_load from_position;
  comm_moves moves;
} comms;

comm_moves comm_moves_init();
void add_comm_move(comm_moves *moves, struct uci_move move);

struct go_args {
  comm_moves searchmoves;
  bool ponder;
  int wtime;
  int btime;
  int winc;
  int binc;
  int movestogo;
  int depth;
  int nodes;
  int mate;
  int movetime;
  bool infinite;
  int perft;
};
bool should_continue(struct engine_message *message, struct go_args* go);

#endif // IPC_H