| 26 | namespace Kanachan{ |
| 27 | |
| 28 | std::any zimo(Kanachan::RoundState &round_state, Kanachan::GameLog &game_log) |
| 29 | { |
| 30 | auto const [action, zimo_tile] = round_state.onZimo(game_log); |
| 31 | |
| 32 | if (action <= 147u) { |
| 33 | // Da Pai (打牌) |
| 34 | // この時点ではロンされる可能性があるため立直は成立しない. |
| 35 | // また,立直が確定しない限り四家立直も確定しない. |
| 36 | KANACHAN_ASSERT((zimo_tile < 37u)); |
| 37 | std::uint_fast8_t const tile = action / 4u; |
| 38 | // 親の配牌14枚のうちどれが第一自摸であるかの区別が存在しないため, |
| 39 | // 親の第一打牌は常に手出しになる. |
| 40 | bool const moqi = round_state.getNumLeftTiles() == 69u ? false : ((action - tile * 4u) / 2u == 1u); |
| 41 | bool const lizhi = ((action - tile * 4u - moqi * 2u) == 1u); |
| 42 | auto dapai = std::bind( |
| 43 | &Kanachan::dapai, std::ref(round_state), tile, moqi, lizhi, std::ref(game_log)); |
| 44 | std::function<std::any()> next_step(std::move(dapai)); |
| 45 | return next_step; |
| 46 | } |
| 47 | |
| 48 | if (action == UINT_FAST16_MAX) { |
| 49 | // Da Pai after Li Zhi (立直後の打牌) |
| 50 | KANACHAN_ASSERT((zimo_tile < 37u)); |
| 51 | auto dapai = std::bind( |
| 52 | &Kanachan::dapai, std::ref(round_state), zimo_tile, /*moqi = */true, |
| 53 | /*lizhi = */false, std::ref(game_log)); |
| 54 | std::function<std::any()> next_step(std::move(dapai)); |
| 55 | return next_step; |
| 56 | } |
| 57 | |
| 58 | if (/*148u <= action && */action <= 181u) { |
| 59 | // An Gang (暗槓) |
| 60 | // 暗槓は槍槓が成立する可能性があるため,この時点では四槓散了は確定しない. |
| 61 | KANACHAN_ASSERT((zimo_tile < 37u)); |
| 62 | std::uint_fast8_t const encode = action - 148u; |
| 63 | auto angang = std::bind( |
| 64 | &Kanachan::angang, std::ref(round_state), zimo_tile, encode, std::ref(game_log)); |
| 65 | std::function<std::any()> next_step(std::move(angang)); |
| 66 | return next_step; |
| 67 | } |
| 68 | |
| 69 | if (/*182u <= action && */action <= 218u) { |
| 70 | // Jia Gang (加槓) |
| 71 | // 加槓は槍槓が成立する可能性があるため,この時点では四槓散了は確定しない. |
| 72 | KANACHAN_ASSERT((zimo_tile < 37u)); |
| 73 | std::uint_fast8_t const encode = action - 182u; |
| 74 | auto jiagang = std::bind( |
| 75 | &Kanachan::jiagang, std::ref(round_state), zimo_tile, encode, std::ref(game_log)); |
| 76 | std::function<std::any()> next_step(std::move(jiagang)); |
| 77 | return next_step; |
| 78 | } |
| 79 | |
| 80 | if (action == 219u) { |
| 81 | // Zi Mo Hu (自摸和) |
| 82 | KANACHAN_ASSERT((zimo_tile < 37u)); |
| 83 | auto hule = std::bind(&Kanachan::hule, std::ref(round_state), zimo_tile, std::ref(game_log)); |
| 84 | std::function<std::any()> next_step(std::move(hule)); |
| 85 | return next_step; |
nothing calls this directly
no test coverage detected