Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

副露を含めて 4 枚使いの牌がある手牌で置換数を誤計算する #22

Open
Apricot-S opened this issue Dec 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Apricot-S
Copy link
Owner

Apricot-S commented Dec 2, 2024

参考: nekobean/mahjong-cpp#26

副露牌 (露地牌) を 4 枚使いの判定に含む場合に、以下の手牌の置換数を誤計算する

  • 9m9p569s [999m] [999p] [999s] : 置換数の理論値 3
  • 東東白發中 [中中中] [發發發] [白白白] : 置換数の理論値 3
  • 13556z [111z] [333z] [666z] : 置換数の理論値 3

現在以下の関数で色ごとの部分置換数を補正しているが、これを修正する必要がある。

fn modify_number(replacement_number: u8, necessary_tiles: u16, four_tiles: u16) -> u8 {
const MAX_REPLACEMENT_NUMBER: u8 = 9;
let remaining_necesaary_tiles = necessary_tiles & !four_tiles;
if replacement_number != 0 && remaining_necesaary_tiles == 0 {
MAX_REPLACEMENT_NUMBER
} else {
replacement_number
}
}

@Apricot-S
Copy link
Owner Author

Apricot-S commented Dec 31, 2024

問題の重要性について補足

  • 副露牌 (露地牌) を 4 枚使いの判定に含む場合でも、置換数 2 を 1 と誤計算することはない (1 向聴を聴牌と誤認しない)
  • 置換数の誤計算は常に小さくなる方向に誤計算される

以上により、本ライブラリが念頭においている麻雀対局シミュレーターでの利用においては
本問題は支障をきたすことはない。

麻雀対局シミュレーターでの利用例

  • プレイヤーが立直可能かの判定
  • プレイヤーが和了可能かの判定
  • 荒牌平局時プレイヤーが聴牌宣言可能かの判定

また効率化のため、一度向聴数を計算した後は向聴数の分手出しを行うまで向聴数を計算しない

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant