Libsaki
Core library of Pancake Mahjong
ai.h
1 #ifndef SAKI_AI_H
2 #define SAKI_AI_H
3 
4 #include "../table/table_tester.h"
5 
6 
7 
8 namespace saki
9 {
10 
11 
12 
15 class Ai : public TableDecider
16 {
17 public:
18  class Limits
19  {
20  public:
21  bool noBark() const;
22  bool noRiichi() const;
23  bool noAnkan() const;
24  bool noOut(const T37 &t) const;
25 
26  void addNoBark();
27  void addNoRiichi();
28  void addNoAnkan();
29  void addNoOutAka5();
30  void addNoOut(T34 t);
31 
32  private:
33  bool mNoBark = false;
34  bool mNoRiichi = false;
35  bool mNoAnkan = false;
36  bool mNoOutAka5 = false;
37  std::bitset<34> mNoOut34s;
38  };
39 
40  static std::unique_ptr<Ai> create(Girl::Id id);
41  static Action thinkStdDrawnAttack(const TableView &view);
42 
43  Ai() = default;
44  virtual ~Ai() = default;
45 
46  Ai(const Ai &copy) = delete;
47  Ai &operator=(const Ai &assign) = delete;
48 
49  Decision decide(const TableView &view) final;
50 
51 protected:
52  Action maxHappy(const TableView &view);
53  virtual Action thinkIrs(const TableView &view);
54  virtual Action think(const TableView &view, Limits &limits);
55 
56  Action placeHolder(const TableView &view);
57 
58  void antiHatsumi(const TableView &view, Limits &limits);
59  void antiToyone(const TableView &view, Limits &limits);
60 
61  Action thinkChoices(const TableView &view, Limits &limits);
62 
63  Action thinkDrawn(const TableView &view, Limits &limits);
64  Action thinkDrawnAggress(const TableView &view, Limits &limits);
65  Action thinkDrawnAttack(const TableView &view, Limits &limits);
66  Action thinkDrawnDefend(const TableView &view, Limits &limits, const util::Stactor<Who, 3> &threats);
67 
68  Action thinkBark(const TableView &view, Limits &limits);
69  Action thinkBarkAttack(const TableView &view, Limits &limits);
70  Action thinkBarkDefend(const TableView &view, Limits &limits, const util::Stactor<Who, 3> &threats);
71 
72  Action thinkAttackStep(const TableView &view, const util::Range<Action> &outs);
73  Action thinkAttackEff(const TableView &view, const util::Range<Action> &outs);
74  Action thinkDefendChance(const TableView &view, const util::Range<Action> &outs,
75  const util::Stactor<Who, 3> &threats);
76 
77  bool afraid(const TableView &view, util::Stactor<Who, 3> &threats);
78  bool testRiichi(const TableView &view, Limits &limits, Action &riichi);
79 
80  int chance(const TableView &view, Who tar, T34 t);
81  int ruleChance(const TableView &view, Who tar, T34 t);
82  int logicChance(const TableView &view, T34 t);
83 
84  util::Stactor<Action, 14> listOuts(const TableView &view, const Limits &limits);
85  util::Stactor<Action, 14> listRiichisAsOut(const Hand &hand, const Choices::ModeDrawn &mode,
86  const Limits &limits);
87  util::Stactor<Action, 44> listCp(const Hand &hand, const Choices::ModeBark &mode,
88  const T37 &pick, bool noChii = false);
89 };
90 
91 
92 
93 } // namespace saki
94 
95 
96 
97 #endif // SAKI_AI_H
bool testRiichi(const TableView &view, Limits &limits, Action &riichi)
Definition: ai.cpp:398
Definition: choices.h:139
Definition: ai.h:15
Definition: tile.h:25
Definition: choices.h:150
Definition: table_tester.h:13
Definition: action.h:27
Definition: ai.cpp:18
Definition: table_view.h:18
Definition: hand.h:17
Definition: stactor.h:34
Definition: tile.h:353
Definition: table_tester.h:18
Definition: ai.h:18
Stactor = statically allocated vector.
Definition: stactor.h:247
Definition: who.h:14