-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRules.cpp
More file actions
53 lines (46 loc) · 865 Bytes
/
Copy pathRules.cpp
File metadata and controls
53 lines (46 loc) · 865 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
51
52
53
#include "Rules.hpp"
bool thisRowIsComplete(States theRow[3])
{
for(int i=1;i<3;i++)
{
if(theRow[i]!=theRow[0])
{
return false;
}
}
return true;
}
States Rules::isWinner(States TheGame[3][3])
{
States col[3];
States hor[3];
States nor[3];
States row[3];
for(int i=0;i<3;i++)
{
hor[i]=TheGame[i][i];
nor[i]=TheGame[3-i][i];
for(int j=0;j<3;j++)
{
row[j]=TheGame[i][j];
col[j]=TheGame[j][i];
}
if(thisRowIsComplete(row))
{
return row[0];
}
if(thisRowIsComplete(col))
{
return col[0];
}
}
if(thisRowIsComplete(hor))
{
return hor[0];
}
if(thisRowIsComplete(nor))
{
return nor[0];
}
return mt;
}