Coverage Report

Created: 2025-09-03 03:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/nix/store/i1aar97n7b4yf8rk94p66if25brfvvdx-gqvzl8a5pvrg3xj44q0msrndcripi8dk-source/src/scoring/yakus/maxbranches.cc
Line
Count
Source
1
#include "scoring/yakus/maxbranches.h"
2
3
#include <array>
4
#include <vector>
5
6
#include "analysis/handnode.h"
7
#include "types/gamestate.h"
8
#include "types/sets.h"
9
10
namespace mahjong::yaku {
11
bool isMaxBranches(const GameState& state, int player,
12
0
                   const std::vector<const mahjong::Node*>& /*branch*/) {
13
0
  const int start = state.hands.at(player).live[0].getPieceNum();
14
0
  const int suit = state.hands.at(player).live[0].getSuit();
15
0
  std::array<int, 6> sets = {};
16
0
  const std::array<int, 6> final = {3, 3, 2, 2, 2, 2};
17
0
  for (const auto& piece : state.hands.at(player).live) {
18
0
    if (piece.getSuit() != suit) {
19
0
      return false;
20
0
    }
21
0
    if (piece.getPieceNum() < start || piece.getPieceNum() > start + 5) {
22
0
      return false;
23
0
    }
24
0
    sets.at(piece.getPieceNum() - start)++;
25
0
  }
26
0
  for (const auto& meld : state.hands.at(player).melds) {
27
0
    if (meld.start.getSuit() != suit) {
28
0
      return false;
29
0
    }
30
0
    if (meld.start.getPieceNum() < start ||
31
0
        meld.start.getPieceNum() > start + 3) {
32
0
      return false;
33
0
    }
34
0
    if (meld.type >= SetType::kKan) {
35
0
      if (meld.start.getPieceNum() != start &&
36
0
          meld.start.getPieceNum() != start + 1) {
37
0
        return false;
38
0
      }
39
0
      sets.at(meld.start.getPieceNum() - start) += 3;
40
0
    }
41
0
    if (meld.type == SetType::kPon) {
42
0
      sets.at(meld.start.getPieceNum() - start) += 3;
43
0
    }
44
0
    if (meld.type == SetType::kChi) {
45
0
      sets.at(meld.start.getPieceNum() - start)++;
46
0
      sets.at(meld.start.getPieceNum() - start + 1)++;
47
0
      sets.at(meld.start.getPieceNum() - start + 2)++;
48
0
    }
49
0
  }
50
0
  for (int i = 0; i < 6; i++) {
51
0
    if (sets.at(i) != final.at(i)) {
52
0
      return false;
53
0
    }
54
0
  }
55
0
  return true;
56
0
}
57
58
// REGISTER_YAKU({
59
//     .id = "maxbranches",
60
//     .name = "Max Branches",
61
//     .type = Yaku::kYakuman,
62
//     .value = 13,
63
//     .is_yaku_func = yaku::isMaxBranches,
64
// });
65
}  // namespace mahjong::yaku