/
engine.c
148 lines (111 loc) · 2.38 KB
/
engine.c
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//engine.c
#include "stdio.h"
#include "header.h"
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#define FEN6 "r1b1k2r/ppppnppp/2n2q2/2b5/3NP3/2P1B3/PP3PPP/RN1QKB1R w KQkq - 0 1"
#define MATE "2rr3k/pp3pp1/1nnqbN1p/3pN3/2pP4/2P3Q1/PPB4P/R4RK1 w - -"
int main(int argc,char *argv[])
{
Allinit();
S_BOARD pos[1];
S_SEARCHINFO info[1];
info->quit = FALSE;
info->depth = SETDEPTH;
pos->hashtable->ptable=NULL;
inithashtable(pos->hashtable,64);
setbuf(stdin,NULL);
setbuf(stdout,NULL);
int argnum =0;
for(argnum = 0; argnum < argc; argnum++)
{
if(strncmp(argv[argnum],"NoBook",6)==0)
{
engineoptions->usebook = FALSE;
printf("Book Off\n");
}
}
printf("Welcome to abhi_engine! type cons for console mode ...\n");
char line[256];
while(TRUE)
{
memset(line,0,sizeof(line));
fflush(stdout);
if(!fgets(line,256,stdin))
continue;
if(line[0]=='\n')
continue;
if(!strncmp(line,"uci",3))
{
uci_loop(pos,info);
if(info->quit == TRUE)
break;
continue;
}
else if(!strncmp(line,"xboard",6))
{
xboard_loop(pos,info);
if(info->quit == TRUE)
break;
continue;
}
else if(!strncmp(line,"cons",4))
{
console_loop(pos,info);
if(info->quit == TRUE)
break;
continue;
}
else if(!strncmp(line,"quit",4))
break;
}
free(pos->hashtable->ptable);
cleanpolybook();
return 0;
}
/*
*
*
S_BOARD board[1];
initpvtable(board->pvtable);
S_MOVELIST list[1];
S_SEARCHINFO info[1];
parse_fen(FEN6,board);
//perfttest(5,board);
char input[6];
int move = NOMOVE;
int pvnum = 0;
int max = 0;
while(TRUE)
{
printboard(board);
printf("please enter a move > ");
fgets(input,6,stdin);
if(input[0]=='q')
break;
else if(input[0]=='t')
takemove(board);
else if(input[0]=='s')
{
info->depth=6;
info->starttime = gettime();
info->stoptime = gettime() + 200000;
searchposition(board,info);
}
else
{
move = parsemove(input,board);
if(move != NOMOVE)
{
storepvmove(board,move);
makemove(board,move);
//if(isrepetition(board))
//printf("Repetition occured");
}
else
printf("Move not passed: %s\n",input);
}
fflush(stdin);
}
*/