Repository navigation
#61 ロン合法source用のprivileged transaction観測hookを追加する - #62
Merged
Merged
Conversation
- RoundState.enable_transaction_observation()で、成功transactionごとの semantic step(追加event + 全席checkpoint)をcommit時だけ公開する - 反応不要の打牌・暗槓をREACTION_WINDOW_SKIPPEDとして残し、反応解決・ 槓成立・立直成立/不成立・終局を順序どおりに分ける - 追加eventの全step帰属と、最後のstepとcommit後盤面の一致をcommit時に検査する - run_hanchan(on_transaction_observation=...)で配牌を含む各transactionを渡す。 未指定時はstepを作らず、従来の進行・結果は変わらない Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01CgaL38rjBCKr1NBpaUNUAL
Owner
Author
20半荘での観測付き確認(head
|
| step | 件数 |
|---|---|
| round_started | 241 |
| draw | 16,870 |
| turn_choice | 16,870 |
| reaction_window_skipped | 13,834 |
| reaction_resolved | 3,036 |
| round_ended | 241 |
所要時間:観測無し 312.8s、観測有り 322.4s(約3%増)。
この確認では出なかったケース:上の選択規則は立直・槓を選ばないので、kan_confirmed と riichi_finalized はこの20半荘では1件も出ていない。これらは tests/test_transaction_observation.py の固定局面テストで確認している(宣言牌の反応不要/全員pass/鳴き/ロン、暗槓のwindowあり/なし、加槓の槍槓pass/ロン)。実対局での出現は lisbun/lisjong-arena#457 のpilotで確認する想定。
Generated by Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #61
Before:
run_hanchan()の既存callbackは成功transaction後のplayer-safeな結果だけを渡すため、打牌→反応不要の解決→立直成立、反応解決→加槓成立、暗槓宣言→成立のように1つのtransaction内で進む順序と中間状態を取り出せなかった。After:
run_hanchan(on_transaction_observation=...)を指定すると、配牌を含む各round transactionについて、内部semantic step(追加event + 全席checkpoint)を順に持つTransactionObservationを受け取れる。未指定時は従来どおりで、stepも作らない。lisbun/lisjong#262 のsource契約(docs/ron-legal-source.md @ 994f529)をArena(lisbun/lisjong-arena#457)が実対局から記録するための、engine側の観測境界である。``
How
transaction_observation.py:TransactionStepKind(ROUND_STARTED/DRAW/TURN_CHOICE/REACTION_WINDOW_SKIPPED/REACTION_RESOLVED/KAN_CONFIRMED/RIICHI_FINALIZED/ROUND_ENDED)と、immutableなSeatCheckpoint/RoundCheckpoint/TransactionStep/TransactionObservation。PlayerState・Wallは持たない。RoundStateenable_transaction_observation()以後、既存の各遷移点でworking copyからstepを記録する。stepはcommit成功時だけlast_transaction_stepsへ公開され、失敗transactionのstepは捨てられる。REACTION_WINDOW_SKIPPED(機会なし)として残る。明示windowはREACTION_RESOLVEDで、そのReactionsResolvedEventが候補・選択・capable/selected/awarded/passed・解決を持つ。REACTION_RESOLVEDの中で適用される。加槓・暗槓の成立はKAN_CONFIRMED、宣言牌への反応後の立直成立/不成立はRIICHI_FINALIZED、終局は精算前のROUND_ENDED。RoundInvariantError。_mark()は何もしない。遷移順序・判定logicには触れていない(_finish_roundをstatic methodからmethodへ変えただけ)。driver.run_hanchan():start_round()の配牌を1 stepのROUND_STARTEDとして渡し、各round transactionでは既存callbackがreturnした後にTransactionObservation(round_ordinal、revision、commit後のphase/current seat、steps、同じtransactionのSelectorDecisionCommit)を渡す。callback例外はfail-fastで伝播する。docs/architecture.mdにprivilegedな境界(selector・player-safe deliveryへ渡さないこと)を追記した。engineはlisjong/Arenaへ依存しない。Learning wire・label・特徴量は実装しておらず、Arenaがlisjongの固定wireへprojectionする。
Tests
tests/test_transaction_observation.py(22件)last_transaction_stepsが変わらないこと、event全帰属、値のimmutabilityRoundState.eventsと一致し、最後のcheckpointがcommit後盤面と一致する。player-safe delivery・selector入力にprivileged型が含まれないこと、callback失敗のfail-fastローカル確認:Ruff format/check、
git diff --check。中核のtransition codeに触るため、engineのunittestもローカルで全件実行した(1503件成功)。🤖 Generated with Claude Code
https://claude.ai/code/session_01CgaL38rjBCKr1NBpaUNUAL
Generated by Claude Code