Libsaki
Core library of Pancake Mahjong
princess.h
1 #ifndef SAKI_PRINCESS_H
2 #define SAKI_PRINCESS_H
3 
4 #include "table.h"
5 
6 
7 
8 namespace saki
9 {
10 
11 
12 
16 struct HrhInitFix
17 {
18 public:
19  enum class Priority { HIGH, LOW, NONE };
20 
21  struct LoadArgs
22  {
23  LoadArgs(T37 t, int c) : tile(t), ct(c) {}
24  T37 tile;
25  int ct;
26  };
27 
28  Priority priority = Priority::NONE;
29  util::Stactor<T37, 13> targets;
31 };
32 
33 
34 
39 {
40 public:
47  enum class Claim { NONE, ANY, ALL, FOUR };
48 
49  virtual ~HrhBargainer() = default;
50  virtual Claim hrhBargainClaim(int plan, T34 t) = 0;
51  virtual int hrhBargainPlanCt() = 0;
52  virtual void onHrhBargained(int plan, Mount &mount) = 0;
53 };
54 
55 
56 
57 class Princess
58 {
59 public:
60  explicit Princess(const Table &table, util::Rand &rand, Mount &mount,
61  const std::array<std::unique_ptr<Girl>, 4> &girls);
62 
63  Princess(const Princess &copy) = delete;
64  Princess &operator=(const Princess &assign) = delete;
65 
66  std::array<Hand, 4> dealAndFlip();
67 
68 private:
69  void debugCheat(std::array<TileCount, 4> &res);
70  void raid(std::array<TileCount, 4> &inits);
71  void bargain();
72  void beg(std::array<TileCount, 4> &inits);
73  util::Stactor<int, 34> permutation(int size);
74  std::array<Hand, 4> monkey(std::array<TileCount, 4> &nonMonkeys);
75  void fixInit(TileCount &init, const HrhInitFix &fix);
76 
77 private:
78  class BargainResult
79  {
80  public:
81  int plan() const;
82  HrhBargainer *bargainer() const;
83  void set(HrhBargainer *b, int p);
84  bool active() const;
85 
86  private:
87  int mPlan = -1;
88  HrhBargainer *mBargainer = nullptr;
89  };
90 
91  const Table &mTable;
92  util::Rand &mRand;
93  Mount &mMount;
94  const std::array<std::unique_ptr<Girl>, 4> &mGirls;
95  std::array<BargainResult, 4> mBargainResults;
96 };
97 
98 
99 
100 } // namespace saki
101 
102 
103 
104 #endif // SAKI_PRINCESS_H
Interface for working with the &#39;bargain&#39; stage.
Definition: princess.h:38
Claim
Definition: princess.h:47
Definition: mount.h:54
Definition: table.h:87
Definition: rand.h:19
Definition: tile.h:25
Definition: tile_count.h:17
Definition: ai.cpp:18
Definition: tile.h:353
Definition: princess.h:21
Stactor = statically allocated vector.
Definition: stactor.h:247
Data object for directly assigning init-hand.
Definition: princess.h:16
Definition: princess.h:57