Extract a DOM-free rules core from makeMove and move generation
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- リファクタリング
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
調査の方向性
Read js/game.js at makeMove (143-276) and move generation (334-461), then check how js/ai.js uses _getAllLegalMoves (132-139). Start by adding the listed undo, SAN, and perft tests; run them with npm test. Done means moves apply to a board copy without DOM access, special-move edits share one implementation, and the stated perft counts pass.
索引モデルが issue の本文から書いたものです。
説明
Summary
makeMove is about 130 lines mixing rule execution, the undo snapshot, notation, game-end detection, rendering, sound and persistence, all against module-level state. Move generation and check detection read the same globals. Special-move rules therefore exist in three places that must change together.
Where
js/game.js:143-276(makeMove)js/game.js:334-461(generateLegalMovesForPiece, including a hand-copied simulation of en passant and castling at:414-444)js/game.js:5-20(module state and DOM lookups at load)js/ai.js:132-139(_getAllLegalMovesreturns[])
Impact
js/game.js is the most-changed source file. The ordering dependencies inside makeMove produced #24, and the generator and canCastle disagreeing produced #22. Two roadmap features are blocked by this shape: a promotion choice needs the move to pause for a dialog, and an AI search needs to apply moves to a board copy without touching the DOM, sound or storage.
Suggested fix
Tests first: undo round trips, SAN for capture, check, mate, castle and en passant, and perft counts from the start position (20, 400, 8902 at depths 1 to 3).
- Extract a pure
applyMove(state, from, to, promotion)that returns the new board, king positions, en passant target and move record.makeMovecalls it and keeps the UI work. - Extract the UI tail (render, status, history, sound, save) into its own function.
- Pass
promotionas a parameter, defaulting to queen. - Change
generateLegalMovesForPieceandcanCastleto take a state object, defaulting to the globals so callers keep working. - Replace the hand-rolled simulation at
:414-444withapplyMove.
Each step leaves the app working.
Acceptance criteria
- Legal moves can be generated and a move applied on a board copy with no DOM
- Special-move board edits live in one place
- Perft counts pass
Getting started
- Relevant files:
js/game.js,js/ai.js - How to run tests:
npm install, thennpm testandnpm run lint - Related docs:
docs/ARCHITECTURE.md,.github/CONTRIBUTING.md
Filed by repo-audit/full-audit at 8a2c86c. Severity: medium. Effort: L. audit-key: tech-debt|js/game.js|makeMove
- 主要言語
- JavaScript
- スター
- 4
- フォーク
- 2
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TMHSDigital/Static_Chess のほかの issue
-
enhancement good first issue severity: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TMHSDigital/Static_Chess#53 ·
-
documentation good first issue severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
TMHSDigital/Static_Chess#49 ·
-
documentation good first issue severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
TMHSDigital/Static_Chess#48 ·
-
documentation severity: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TMHSDigital/Static_Chess#47 ·
-
documentation good first issue severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
TMHSDigital/Static_Chess#46 ·
TMHSDigital/Static_Chess の issue をすべて見る
似ている issue
-
good first issue tests
難易度 1/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
1️⃣ phase/under-investigation flaky/confirmed flaky/needs-decision type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
growilabs/growi#12246 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
TMHSDigital/Free-Game-Dev-Assets#301 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100