DSH Tianjie Chess Plugin: Chinese Chess Human vs Computer

Preface

In the development and usage of DeepSeek Harness (DSH) WebUI, beyond standard conversational interactions, it is sometimes necessary to integrate lightweight entertainment features to enrich the interface or serve as demo cases. Addressing this need, dsh-chess-xq-plugin provides a browser-based Chinese Chess (Xiangqi) man-vs-machine gaming solution.

Plugin Introduction

Named “Tianjie Xiangqi” (Heavenly Realm Chess) and maintained by feverZHONG, this plugin falls under the category of entertainment/cosmetic tools. It integrates into the DSH WebUI via a floating panel, solving the problem of quickly building a chess application with a complete rule engine and AI capabilities in a standalone environment.

Core Features

The plugin offers the following core capabilities:

  • Floating Panel & Position Memory:The left end of the input box’s tool row features a “♟ Chess” toggle to open the floating panel. The panel’s title bar supports dragging, and its position is automatically saved, restoring to the last location upon reopening.
  • Board Layout:Inside the floating panel, the chessboard is on the left, and the move history is on the right. The latest move appears at the top of the history list, refreshing in real-time during gameplay.
  • Complete Rule Engine:Includes full Chinese Chess rules, including move generation, check detection, checkmate determination, stalemate (draw) determination, and flying general detection.
  • AI Battle:The AI plays Black and moves first. It utilizes the alpha-beta search algorithm combined with a position evaluation table, with a default search depth of 3 layers. When the AI is thinking, the panel displays a spinning indicator and the text “This angel is thinking…”.
  • Li Ya’s Dialogue:The character Li Ya has dynamic lines triggered by game scenarios, including opening, checking, being checked, capturing, first kill, exchange, pawn crossing river, endgame, blunder, undo, win/loss, and draw states.
  • Game Controls:Supports undo (retracting a full turn, i.e., one player move + one AI move), and save/load/delete save files (based on FEN format).
  • AI Difficulty Adjustment:In the WebUI settings page, users can adjust the AI’s search depth (1~4 layers) to control the difficulty of the match.

Installation and Activation

The WebUI must be restarted after installation for the plugin to take effect.

dsh plugin --profile web add dsh-chess-xq-plugin-0.1.0.tgz

Typical Usage

  1. Open Panel:Click the “♟ Chess” toggle on the left end of the input box tool row to open the floating panel.
  2. AI Interaction:The AI can control the game via toolbar calls to chess_talk (speak), chess_state (query state), or chess_new_game (start new game).
  3. Adjust Parameters:Adjust AI difficulty in the WebUI settings page.

Use Cases & Notes

  • Applicable Scenarios:Suitable for developers looking to add casual interactive features to DSH WebUI, demonstrate plugin extensibility, or showcase a simple rule engine.
  • Configuration & Saves:Plugin configuration is persisted to $DSH_HOME/dsh-chess-xq-config. Save data is stored in the browser’s localStorage (key: dsh-chess-xq-saves). This implies that switching browsers or clearing the cache will result in the loss of saves.
  • Dependencies & License:The plugin has no Config schema dependencies and is ready to use upon installation. The code is licensed under MIT, and the documentation is licensed under CC BY 4.0.

Conclusion

dsh-chess-xq-plugin is a clearly structured and functionally complete DSH plugin example, demonstrating how to combine game logic, UI interaction, and the DSH tool system. It is a valuable reference implementation for developers seeking to enrich the WebUI interaction experience.

Plugin Directory | GitHub Repository

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye