-
Notifications
You must be signed in to change notification settings - Fork 1
/
BasicAI.h
47 lines (38 loc) · 1.07 KB
/
BasicAI.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
//
// Created by Mitchell on 6/6/2021.
//
#ifndef FLOODIT_AI_BASICAI_H
#define FLOODIT_AI_BASICAI_H
#include "Player.h"
#include "BoardSimple.h"
class BasicAI : public Player
{
private:
public:
BasicAI(std::string n = "Basic AI") : Player(n)
{ displayBoard = false; }
bool getMove(BoardSimple board, int &colour, int &row, int &col);
};
/* == BasicAI::getMove ==
* Chooses it's moved based on the first colour it finds from left-right and top-bottom.
* Row and col are always 0, it looks for the first colour which is not the same as the one at [0][0].
*/
bool BasicAI::getMove(BoardSimple board, int &colour, int &row, int &col)
{
int i = board.grid[0][0];
for (int r = 0; r < board.width; r++)
{
for (int c = 0; c < board.height; c++)
{
if (board.grid[r][c] != i)
{
row = 0;
col = 0;
colour = board.grid[r][c];
return true;
}
}
}
return false;
}
#endif //FLOODIT_AI_BASICAI_H