-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathValueBot.h
78 lines (60 loc) · 2.75 KB
/
ValueBot.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
#include "Hanabi.h"
struct CardKnowledge {
CardKnowledge();
bool mustBe(Hanabi::Color color) const;
bool mustBe(Hanabi::Value value) const;
bool cannotBe(Hanabi::Color color) const;
bool cannotBe(Hanabi::Value value) const;
int value() const;
void setMustBe(Hanabi::Color color);
void setMustBe(Hanabi::Value value);
bool isPlayable;
bool isValuable;
bool isWorthless;
private:
enum Possibility { NO, MAYBE, YES };
Possibility colors_[Hanabi::NUMCOLORS];
Possibility values_[5+1];
};
struct Hint {
int information_content;
int to;
int color;
int value;
Hint();
void give(Hanabi::Server &);
};
class ValueBot final : public Hanabi::Bot {
int me_;
int myHandSize_; /* purely for convenience */
/* What does each player know about his own hand? */
std::vector<std::vector<CardKnowledge> > handKnowledge_;
/* What cards have been seen so far? */
int cardCount_[Hanabi::NUMCOLORS][5+1];
/* Returns the lowest value of card that is currently playable. */
int lowestPlayableValue() const;
bool couldBeValuable(int value) const;
void invalidateKnol(int player_index, int card_index);
void seePublicCard(const Hanabi::Card &played_card);
void wipeOutPlayables(const Hanabi::Server &server, const Hanabi::Card &played_card);
void makeThisValueWorthless(const Hanabi::Server &server, Hanabi::Value value);
/* Returns -1 if the named player is planning to play a card on his
* turn, or if all his cards are known to be valuable. Otherwise,
* returns the index of his oldest not-known-valuable card. */
int nextDiscardIndex(const Hanabi::Server &server, int player) const;
Hint bestHintForPlayer(const Hanabi::Server &server, int to) const;
bool maybePlayLowestPlayableCard(Hanabi::Server &server);
bool maybeGiveHelpfulHint(Hanabi::Server &server);
bool maybeGiveValuableWarning(Hanabi::Server &server);
bool maybeDiscardWorthlessCard(Hanabi::Server &server);
bool maybeDiscardOldCard(Hanabi::Server &server);
public:
ValueBot(int index, int numPlayers, int handSize);
void pleaseObserveBeforeMove(const Hanabi::Server &) override;
void pleaseMakeMove(Hanabi::Server &) override;
void pleaseObserveBeforeDiscard(const Hanabi::Server &, int from, int card_index) override;
void pleaseObserveBeforePlay(const Hanabi::Server &, int from, int card_index) override;
void pleaseObserveColorHint(const Hanabi::Server &, int from, int to, Hanabi::Color color, Hanabi::CardIndices card_indices) override;
void pleaseObserveValueHint(const Hanabi::Server &, int from, int to, Hanabi::Value value, Hanabi::CardIndices card_indices) override;
void pleaseObserveAfterMove(const Hanabi::Server &) override;
};