Skip to content

fix: offer chi/pon on the haitei discard - #277

Open
adentong wants to merge 2 commits into
shinkuan:v3from
adentong:port/rc-haitei-claims
Open

adentong wants to merge 2 commits into
shinkuan:v3from
adentong:port/rc-haitei-claims

Conversation

@adentong

Copy link
Copy Markdown
Contributor

Closes a pre-existing gap in shared code, observed on a live 2026-08-24 Riichi City capture: riichienv-core 0.4.8 gates chi/pon/kan detection on wall.drawable_count > 0, a stricter variant than the games actually play. With the live wall empty — the hand's final discard at haitei — the engine's claim set comes back empty, can_act goes false, and the bot is never asked. In the capture, the server offered a chi on that discard and the call window burned its full timer with Akagi silent.

Scope

Any hand that plays toward an exhaustive draw hits this: the final discard happens at wall == 0, and pon (from any player) or chi (from the previous player) on it is suppressed. Ron is unaffected — the ron arm runs before the wall gate, so houtei raoyui still works. Kan replacement draws (rinshan, dead-wall) also deplete the engine's count, so kan-heavy hands can hit the suppression a few tiles early. Platform-independent: the same tracker/engine path feeds Majsoul and Tenhou, where the visible effect is the bot going quiet on a claim the server is offering.

Fix

After applying a wall-empty dahai, re-run the engine's own claim detection with the gate satisfied (bumping drawable_count by one and restoring it immediately — the ron arm already ran during apply with the true haitei conditions) and splice the chi/pon claims into current_claims, setting the response phase. Kan stays gated: an empty live wall is the engine's own call there. 4p and sanma twins.

A unit test pins the offer (chi from the previous seat at wall 0) and that the wall is restored after the splice; a tile we cannot use still yields nothing.

The second commit fixes pre-existing clippy --all-targets failures in profile.rs test helpers that the floating stable toolchain newly flags on v3 — any PR currently trips them.

cargo test green on top of latest v3 (937 passing), clippy -D warnings and rustfmt clean.

riichienv-core 0.4.8 gates chi/pon/kan detection on
wall.drawable_count > 0, a stricter variant than Riichi City plays.
Observed on a live 2026-08-24 capture: the server offered a chi on a
discard made with the live wall empty (the hand's final discard at
haitei), the engine's claim set came back empty, can_act went false,
and the bot was never asked — the call window burned its full timer
with Akagi silent.

Any hand that plays toward an exhaustive draw hits this: the final
discard happens at wall == 0, and pon (from any player) or chi (from
the previous player) on it is suppressed. Ron is unaffected — the ron
arm runs before the wall gate, so houtei raoyui still works. Kan
replacement draws also deplete the engine's count despite coming from
the dead wall, so kan-heavy hands can hit the suppression a few tiles
early.

Fix: after applying a wall-empty dahai, re-run the engine's own claim
detection with the gate satisfied (bumping drawable_count by one and
restoring it immediately — the ron arm already ran during apply with
the true haitei conditions) and splice the chi/pon claims into
current_claims, setting the response phase. Kan stays gated: an empty
live wall is the engine's own call there. 4p and sanma twins; a unit
test pins the offer and the wall restoration.
CI's clippy pass lints test targets too, and the floating stable
toolchain newly flags the single-element &[String] slices built via
clone in profile.rs — pre-existing on v3, hit by any PR that runs
clippy --all-targets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant