-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChampion.cpp
More file actions
50 lines (46 loc) · 786 Bytes
/
Champion.cpp
File metadata and controls
50 lines (46 loc) · 786 Bytes
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
#include "Champion.h"
Champion::Champion() : Player("Roee and Oran")
{
}
const string Champion::name() const
{
return "Roee and Oran";
}
const Coordinate Champion::play(const Board & board)
{
size_t last = board.size() - 1;
if (myChar == 'X')
{
for (size_t i = 0; i < board.size(); i++)
{
if (board[{i, i}] == '.')
{
return { i,i };
}
}
}
else
{
if (board[{0, 0}] == 'X' && board[{0, 1}] == 'X')
{
for (size_t i = 0; i < board.size(); i++)
{
if (board[{i, last}] == '.')
{
return {i, last};
}
}
}
else if (board[{0, 0}] == 'X' && board[{1, 0}] == 'X')
{
for (size_t i = 0; i < board.size(); i++)
{
if (board[{last, i}] == '.')
{
return { last, i };
}
}
}
}
return Coordinate(last, last);
}