Make the AI opponent skeleton playable (single-player mode)

未關閉
#54 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
35/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
javascript
領域
game-dev

研究方向

Start with js/ai.js and js/game.js, especially the listed move generation and search methods, then read docs/ARCHITECTURE.md. The proposal spans legal move generation, search, UI controls, and responsive play, with a Web Worker question still open. Done means a player can choose a side, start a game against the computer, and the computer always makes legal moves while the UI stays responsive.

由索引模型根據 Issue 內容生成。

描述

enhancement severity: medium

Summary

The app supports only two players on one device. js/ai.js holds an AI skeleton, but it is not loaded and cannot produce a move.

Where

  • js/ai.js:132-139 (_getAllLegalMoves returns []), js/ai.js:76-86 (findBestMove therefore resolves null), js/ai.js:151-161 (_minimax returns 0)
  • js/config.js:13, js/config.js:26 (AI_DIFFICULTY: 'easy' does not match the EASY/MEDIUM/HARD keys at js/ai.js:9-13)
  • index.html:65-71 (script not loaded), js/game.js:313-325 (generateAllLegalMoves)

Proposal

  1. Make move generation and apply/unapply take a board argument so search can run on a copy (#31).
  2. Ship a first version that plays a random legal move, then a material-greedy one-ply move using the existing _evaluatePosition.
  3. Add minimax with alpha-beta at depth 2 to 3.
  4. UI: a "Play vs computer" toggle with side and difficulty selectors; lock input while the AI is thinking; Undo takes back two plies in AI mode. Normalise the difficulty key casing.

Open question: depth 4 on the main thread may stall the UI. A Web Worker needs the engine code to be DOM-free, which game.js is not today.

Who benefits

Solo visitors to the hosted page, who currently have no one to play against.

Acceptance criteria

  • A player can start a game against the computer and pick a side
  • The computer always plays a legal move
  • The UI stays responsive while it thinks

Getting started

  • Relevant files: js/ai.js, js/game.js, js/config.js, index.html
  • How to run tests: npm install, then npm test and npm run lint
  • Related docs: docs/ARCHITECTURE.md, .github/CONTRIBUTING.md

Filed by repo-audit/full-audit at 8a2c86c. Severity: medium. Effort: L. audit-key: enhancement|js/ai.js|ChessAI._getAllLegalMoves

主要語言
JavaScript
星號
4
分支
2
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/Static_Chess 的其他 Issue

查看 TMHSDigital/Static_Chess 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。