駒フェイズ直後に相手の囲み駒・石を除去するよう修正#25
Open
rehakomoon wants to merge 1 commit into
Open
Conversation
Per the official rule (shogoss-comprehensive-rules.md §4):
「駒フェーズの後に,すぐに相手の石・駒の囲みを判定し囲まれていれば
除去される(自分の駒は除去されない).」
Previously `one_turn` went straight from `play_piece_phase` to
`place_stone`, so if a piece move surrounded an opponent's stone, the
stone was still on the board when `place_stone` ran, and placing a
stone on the (supposedly-now-empty) square failed with
「マスは既に埋まっています」.
Insert the opponent-removal step between the two phases, reusing the
existing helper (signature loosened from `StonePhasePlayed` to a
structural `{ board, hand_of_black, hand_of_white }`).
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.
// Claude Codeで実装
従来の
one_turnはplay_piece_phase → place_stone → resolve_after_stone_phaseの順で進み、駒フェイズと石フェイズの間に囲み除去が走りません。そのため、駒フェイズの着手で相手の石を四方から囲み、同ターンでそのマスへ自分の石を打つ手順でエラー「
…のマスは既に埋まっています」が発生していました。具体的な再現棋譜(40手目
△5六ビ5五で発火):src/index.ts:one_turn内、play_piece_phaseの直後に「相手の囲まれた駒・石の除去」呼び出しを追加src/after_stone_phase.ts: 既存のremove_surrounded_enitities_from_board_and_add_to_hand_if_necessaryをexport化し、受け取り型をStonePhasePlayedから構造的部分型{ board, hand_of_black, hand_of_white }に緩和(PiecePhasePlayedでも呼べるようにするため。ロジックは不変)src/tests/place_stone.test.ts: 最小再現の回帰テストを追加