-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.h
58 lines (46 loc) · 2.38 KB
/
Player.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
#ifndef PLAYER_H
#define PLAYER_H
#include <string>
#include "Side.h"
#include"Board.h"
#include <iostream>
class AlarmClock;
class Player {
public:
//Create a Player with the indicated name.
Player(std::string name);
//Return the name of the player.
std::string name() const;
//Return false if the player is a computer player.Return true if the player is human.Most kinds of players will be computer players.
virtual bool isInteractive() const;
//Every concrete class derived from this class must implement this function so that if the player were to be playing side s and had to make a move given board b, the function returns the move the player would choose.If no move is possible, return −1.
virtual int chooseMove(const Board& b, Side s) const = 0;
//Since this class is designed as a base class, it should have a virtual destructor.
virtual ~Player();
private:
string m_name;
};
//A HumanPlayer chooses its move by prompting a person running the program for a move(reprompting if necessary until the person enters a valid hole number), and returning that choice.We will never test for a situation where the user doesn't enter an integer when prompted for a hole number. (The techniques for dealing with the issue completely correctly are a distraction to this project, and involve either a function like stoi or strtol, or the type istringstream.)
class HumanPlayer : public Player {
public:
HumanPlayer(std::string name);
virtual bool isInteractive() const;
virtual int chooseMove(const Board& b, Side s) const;
};
//A BadPlayer is a computer player that chooses an arbitrary valid move and returns that choice. "Arbitrary" can be what you like : leftmost, nearest to pot, fewest beans, random, etc..The point of this class is to have an easy - to - implement class that at least plays legally.
class BadPlayer : public Player {
public:
BadPlayer(std::string name);
virtual int chooseMove(const Board& b, Side s) const;
//virtual ~BadPlayer() {};
};
class SmartPlayer: public Player {
public:
SmartPlayer(std::string name);
virtual int chooseMove(const Board& b, Side s) const;
private:
void chooseMove(AlarmClock &ac,const Board& b, Side s, int & bestHole, int& value, int depth) const;
int evaluate(const Board& b) const;
bool completeMove(Side s, int hole, Board &b, Side& endSide, int& endHole) const;
};
#endif // !PLAYER_H