-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
53 lines (49 loc) · 1.14 KB
/
main.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
//
// main.cpp for Chess IA in /home/wilmot_p/PROG/C++/[2012-11-26] - Chess IA
//
// Made by WILMOT Pierre
// Login <[email protected]>
//
// Started on Mon Nov 26 20:42:26 2012 WILMOT Pierre
//
#include <iostream>
#include "ChessBoard.hpp"
#include "Move.hpp"
#include "MinMax.hpp"
#include "OptionsParser.hpp"
#include "UCI.hpp"
#include "Action.hpp"
#include "LogManager.hpp"
int main(int ac, char **av)
{
try
{
OptionsParser op(ac, av);
ChessBoard board;
MinMax mm(op.getDepth());
UCI uci("ChessIA", "Pierre WILMOT");
Action *action;
while (!uci.mustQuit())
{
action = uci.getAction();
if (action)
{
if (action->getType() == Action::IsReady)
uci.readyOK();
else if (action->getType() == Action::Position)
board.setFromFen(action->getFen());
else if (action->getType() == Action::Go)
{
const Move m = mm.getBestMove(board, GameData::White);
uci.sendMove(m);
}
}
}
}
catch(std::exception& e)
{
std::cerr << "Unhandled Exception reached the top of main: "
<< e.what() << ", application will now exit" << std::endl;
return (2);
}
}