-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSource.cpp
More file actions
87 lines (60 loc) · 1.47 KB
/
Source.cpp
File metadata and controls
87 lines (60 loc) · 1.47 KB
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
79
80
81
82
83
84
85
86
87
#include <iostream>
#include<stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
int main()
{
//initialize board
int board[6][6]; // 2d array matrix
int pScore = 0;
int aScore = 0;
srand((unsigned int)time(NULL));
for (int i = 0; i < 6; i++)
{
for (int j = 0 ; j < 6; j++){
board[i][j] = 0; //sets a clear board
cout << board[i][j] << " "; // to display and have spaces in between
}
cout << endl; // to add the rows
}
cout << endl;
int turn = 1; // for a.i. turn
int row = (rand()%6);
int col = (rand()%6);
//assign the coordinate for first move
//board[row][col] = 1;
for (int i = 0; i < 36; i++){
int check = 0;
while(check == 0){
if(board[row][col] == 1 || board[row][col] == -1){
row = (rand()%6);
col = (rand()%6);
}else{
check = 1;
}
}
if(turn == 1){
board[row][col] = 1;
pScore = checker(board, row, col, turn, pScore);
}else{
board[row][col] = -1;
aScore = checker(board, row, col, turn, aScore);
}
turn *= -1;
}
for (int i = 0; i < 6; i++){
for (int j = 0 ; j <6; j++){
if(board[i][j] == 1)
cout << " ";
cout << board[i][j] << " "; // to display and have spaces in between
}
cout <<endl; // to add the rows
}
cout << "pScore: " << pScore << endl;
cout << "aScore: " << aScore << endl;
//assign the board function
// }
system("pause");
return 0;
}