forked from gomoku/Carbon-Gomoku
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AIwrapper.cpp
72 lines (59 loc) · 1.3 KB
/
AIwrapper.cpp
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
#include "pisqpipe.h"
#include <windows.h>
#include "AICarbon.h"
const char *infotext="name=\"Carbon\", author=\"Michal Czardybon\", version=\"2.2\", country=\"Poland\", www=\"http://mczard.republika.pl/gomoku.en.html\"";
AICarbon *ai;
void brain_init()
{
if(width<5 || height < 5){
pipeOut("ERROR Invalid size of the board");
return;
}
if(width > MAX_BOARD_SIZE || height>MAX_BOARD_SIZE){
pipeOut("ERROR Maximal board size is %d", MAX_BOARD_SIZE);
return;
}
brain_restart();
}
void brain_restart()
{
if(!ai) ai = new AICarbon();
ai->start(width, height);
pipeOut("OK");
}
void brain_my(int x, int y)
{
ai->move(x, y);
}
void brain_opponents(int x, int y)
{
ai->move(x, y);
}
void brain_block(int x, int y)
{
pipeOut("ERROR brain_block not implemented");
}
int brain_takeback(int x, int y)
{
return ai->undo(x, y);
}
void brain_turn()
{
int x, y;
ai->yourTurn(x, y);
ai->move(x, y);
pipeOut("%d,%d", x, y);
}
void brain_end()
{
delete ai;
}
void WriteLog(int points, int nSearched, int speed, int depth, bool debug)
{
pipeOut("%s eval %d, depth %d, nodes %d, speed %d", debug ? "DEBUG" : "MESSAGE",
points, depth, nSearched, speed);
}
long getTime()
{
return (long)GetTickCount();
}