-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathothello_template.cpp
73 lines (65 loc) · 1.38 KB
/
othello_template.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
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
#define B 1
#define W -1
/*Initial Board configuration*/
int board[8][8]={
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
0 , 0 , 0 , B , W , 0 , 0 , 0,
0 , 0 , 0 , W , B , 0 , 0 , 0,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
};
string stratagicMove(int turn);
void updateBoard(string move,int turn);
int main()
{
string opponentMove;
string myMove;
int turn=B;
cin>>opponentMove;
if(opponentMove=="ST") //starting signal send by judge.
{
/* you are black. Play the first move */
myMove=stratagicMove(turn);
updateBoard(myMove,turn);
cout<<myMove;
fflush(stdout);
cin>>opponentMove;
turn= -turn;
}
while(true)
{
/* you are white.*/
/* first update the board with black players move*/
updateBoard(opponentMove,turn);
/*play your move*/
turn= -turn;
myMove=stratagicMove(turn);
updateBoard(myMove,turn);
cout<<myMove;
fflush(stdout);
cin>>opponentMove;
}
}
string stratagicMove(int turn)
{
/* play your strategey accordinly whether you are white or black
which is denoted by turn
*/
/* implement your stratage here......*/
return "A1";
}
void updateBoard(string move,int turn)
{
if(move=="ST" || move =="PS")
return;
int row=move[1]-'0';
int col=move[0]-'A';
board[row][col]=turn;
}