-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
78 lines (63 loc) · 1.63 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
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
/**
* Ryan Domigan <ryan_domigan@[email protected]>
* Kaitlyn Carcia <[email protected]>
* @file /home/ryan/uml/robotics/checkers/main.cpp
* Created on Apr 30, 2014
*
* Main loop, should tie together the AI, vision and movement
*/
#include "./Board.hpp"
#include "./vision.hpp"
#include "movement.hpp"
#include "./AI.hpp"
int main() {
Board logical_board, vision_board;
Grid grid;
bool human_moved = false;
Move move;
AI ai;
{ Sling arm; }
//cout << "logical_board:\n" << logical_board;
vision_board = Board( capture_grid().rotate() );
cout << "vision_board\n" << vision_board << "\n";
cout << "Begin" << endl;
while( true ) {
while( true ) {
vision_board = Board( capture_grid().rotate() );
logical_board.move_fold([&](const Board& bb, const Move&) {
human_moved = color_equal(State::red, vision_board, bb);
if(human_moved) logical_board = bb;
return human_moved;
}, State::red);
if(!human_moved) {
cout << ",";
sleep(0.1);
} else break;
}
//cout << "Human moved\n" << logical_board << endl;;
move = ai(State::black, logical_board);
if( !is(Empty, logical_board.at(move.dst)) ) {
do {
{
Sling arm;
arm().remove_piece(move.dst);
}
{
Sling arm;
arm().execute_move( Move(move.src, logical_board.jump_dst(move)));
}
logical_board.legal_move(move);
move = ai(State::black, logical_board);
} while ( !is(Empty, logical_board.at(move.dst)) );
} else {
logical_board.legal_move(move);
{
Sling arm;
/* Arm at 0,0 and then arm executes move */
arm().reset();
arm().execute_move(move);
}
}
}
return 0;
}