Coverage Report

Created: 2026-11-14 03:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/nix/store/rr0r40cw3mzzbz0sxrnkvnrjpzb82wpc-j27cjzgh5nmq3y8k6hwa6zpi3qgcjia8-source/src/scoring/yakus/outsidehand.cc
Line
Count
Source
1
#include "scoring/yakus/outsidehand.h"
2
3
#include <vector>
4
5
#include "analysis/handnode.h"
6
#include "scoring/yakus.h"
7
#include "scoring/yakus/allterminalsandhonors.h"
8
#include "scoring/yakus/terminalsinallsets.h"
9
#include "types/gamestate.h"
10
#include "types/hand.h"
11
#include "types/sets.h"
12
#include "types/yaku.h"
13
14
namespace mahjong::yaku {
15
bool isOutsideHand(const GameState& state, const Hand& hand,
16
27
                   const std::vector<const mahjong::Node*>& branch) {
17
27
  bool chi = false;
18
139
  for (const auto* node : branch) {
19
139
    if (node->type() == SetType::kChi) {
20
13
      if (node->start().isTerminal() || (node->start() + 2).isTerminal()) {
21
4
        chi = true;
22
9
      } else {
23
9
        return false;
24
9
      }
25
126
    } else {
26
126
      if (!node->start().isTerminal() && !node->start().isHonor()) {
27
0
        return false;
28
0
      }
29
126
    }
30
139
  }
31
18
  for (const auto& meld : hand.melds_range()) {
32
0
    if (meld.type == SetType::kChi) {
33
0
      if (meld.start.isTerminal() || (meld.start + 2).isTerminal()) {
34
0
        chi = true;
35
0
      } else {
36
0
        return false;
37
0
      }
38
0
    } else {
39
0
      if (!meld.start.isTerminal() && !meld.start.isHonor()) {
40
0
        return false;
41
0
      }
42
0
    }
43
0
  }
44
  // Terminals in all Sets and All Terminals and Honors are more valuable and
45
  // score instead of Outside Hand.
46
18
  return chi && !isTerminalsInAllSets(state, hand, branch) &&
47
18
         !isAllTerminalsAndHonors(state, hand);
48
18
}
49
50
REGISTER_YAKU({
51
    .id = "outsidehand",
52
    .name = "Outside Hand",
53
    .type = Yaku::kBonusWhenClosed,
54
    .value = 1,
55
    .is_yaku_func = yaku::isOutsideHand,
56
});
57
}  // namespace mahjong::yaku