-
Notifications
You must be signed in to change notification settings - Fork 1
/
ai.h
92 lines (81 loc) · 1.91 KB
/
ai.h
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
88
89
90
91
92
#pragma once
#include <string>
#include <iostream>
#include <cstdlib>
class AI : public player {
string difficulty;
}
int[][]generatesmap() {
}
int[]generateguess(str difficulty, string[][]guessMap) {
if (difficulty == Easy) {
int coordinateX = rand() % 10;
int coordinateY = rand() % 10;
int guess[2];
while (guessMap[coordinateX][coordinateY]!=~) {
int coordinateX = rand() % 10;
int coordinateY = rand() % 10;
}
int guess[0] = coordinateX;
int guess[1] = coordinateY;
return guess;
}
if (difficulty == Medium) {
int guess[2];
int[][] potentialList = new int [15][2];
int c = 0;
for (int i = 0; i < guessMap.size; i++) {
for (int j = 0; j < guessMap[i].size; j++) {
if (guessMap[i][j] = "*") {
if (guessMap[i][j + 1] == "~") {
potentialList[c][0] = i;
potentialList[c][1] = j + 1;
c++;
}
if (guessMap[i][j -1] == "~") {
potentialList[c][0] = i;
potentialList[c][1] = j -1;
c++;
}
if (guessMap[i+1][j] == "~") {
potentialList[c][0] = i+1;
potentialList[c][1] = j ;
c++;
}
if (guessMap[i-1][j] == "~") {
potentialList[c][0] = i-1;
potentialList[c][1] = j ;
c++;
}
}
}
}
if (potentialList[0][0]==NULL){
int coordinateX = rand() % 10;
int coordinateY = rand() % 10;
while (guessMap[coordinateX][coordinateY] != "~") {
int coordinateX = rand() % 10;
int coordinateY = rand() % 10;
}
int guess[0] = coordinateX;
int guess[1] = coordinateY;
return guess;
}
else {
int counter;
for (int k = 0; k <= 14; k++) {
if (potentialList[k][0]!=NULL) {
counter++;
}
}
}
}
if (difficulty == Hard) {
int coordinateX = rand() % 10;
int coordinateY = rand() % 10
if (hit == true && ship != sunk) {
if (map[][] == ~) {
}
}
}
}