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 枚使いの牌がある手牌で置換数を誤計算する #3

Closed
Apricot-S opened this issue Sep 23, 2024 · 7 comments · Fixed by #6
Closed

4 枚使いの牌がある手牌で置換数を誤計算する #3

Apricot-S opened this issue Sep 23, 2024 · 7 comments · Fixed by #6
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Apricot-S
Copy link
Owner

Apricot-S commented Sep 23, 2024

Nyanten との比較テストにより発見した例 (数値は置換数)

  • 111124m1111z : 正しい値: 2 計算値: 3
  • 1111444478m : 正しい値: 3 計算値: 2
@Apricot-S Apricot-S added bug Something isn't working help wanted Extra attention is needed labels Sep 23, 2024
@Apricot-S
Copy link
Owner Author

Apricot-S commented Sep 23, 2024

条件の変更で
1111444478m
は修正された (未コミット fix/3-miscalculation にコミットした)

代わりに以下の手牌の置換数が誤計算されるようになった

  • 1111247777m 正しい値: 2 計算値: 3
  • 1111247777m1111z 正しい値: 2 計算値: 3

@Apricot-S
Copy link
Owner Author

11 (11) 24 77 77 (カッコは死に対子、雀頭と同じ牌のため対子として数えない)と
111 1 24 777 7 にしか分解できていない

111 12 4 777 7 に分解する必要がある

@Apricot-S Apricot-S changed the title 4 枚使いの牌がある手牌でシャンテン数を誤計算する 4 枚使いの牌がある手牌で置換数を誤計算する Sep 23, 2024
@Apricot-S
Copy link
Owner Author

6ed5572 で面子・ターツ・対子の数が同じときは4枚使いの孤立牌が少ない分解を選ぶようにしたところすべての単体テストが通った。

しかし、Nyanten との比較テストで手牌 7 枚以降のとき不明なエラーが発生するようになった。
test プロファイルでビルドしたところ、Ctrl+C で強制終了するまでテストが終了しなくなった。

@Apricot-S
Copy link
Owner Author

しかし、Nyanten との比較テストで手牌 7 枚以降のとき不明なエラーが発生するようになった。 test プロファイルでビルドしたところ、Ctrl+C で強制終了するまでテストが終了しなくなった。

以下のデバッグ用 println! が残っていたせいだと思われる。

                println!(
                    "雀頭: {:?}, 面子数: {}, 搭子数: {}, 対子数: {}, 孤立牌数: {}, 置換数: {} ",
                    jiangpai, num_mianzi, num_dazi, num_duizi, num_gulipai, temp
                );

@Apricot-S Apricot-S self-assigned this Sep 24, 2024
@Apricot-S Apricot-S pinned this issue Sep 24, 2024
@Apricot-S
Copy link
Owner Author

f15459a で単体テストはすべて通った。
また、Nyanten との比較テストで 10 枚のときまでが通った。

比較テスト実行時間の参考

    Finished `release` profile [optimized] target(s) in 7.97s
     Running unittests src/lib.rs (target/release/deps/xiangting-39300c774503dea4)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 115 filtered out; finished in 0.00s

     Running tests/correctness.rs (target/release/deps/correctness-5dd416d06c82eabe)

running 1 test
test tests::verify_correctness_10 has been running for over 60 seconds
test tests::verify_correctness_10 ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 3065.95s

     Running tests/nyanten.rs (target/release/deps/nyanten-c69f4217025dad28)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

@Apricot-S
Copy link
Owner Author

Apricot-S commented Sep 24, 2024

副露牌を計算に含めないルールに関してはおそらく修正が完了したが、含めるルールで誤計算することがわかった。

例: 13333m11z [2222m, 4444m] 正しい値: 2、計算結果: 3

先にターツを抜いて計算した後でターツをブロックに含めるかを待ちの有無で判定しているのが原因と思われる。
先にターツの待ちの有無を判定し、待ちがあるときだけターツを抜いて計算すればよいと思われる。

@Apricot-S
Copy link
Owner Author

2d331ab にて修正した。

@Apricot-S Apricot-S linked a pull request Sep 24, 2024 that will close this issue
@Apricot-S Apricot-S unpinned this issue Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant