npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

koishi-plugin-play-go-chess

v0.2.2

Published

棋类游戏插件 - 支持围棋(含联棋)、五子棋(无禁手/有禁手)、黑白棋,含战绩统计

Readme

koishi-plugin-play-go-chess

棋类游戏插件,支持围棋(含四人联棋)、五子棋(无禁手/有禁手)、黑白棋。Canvas 渲染棋盘含坐标标注,对局无限时长仅可主动结束,落子即自动加入对局(先落子者执黑),数据库持久化三棋战绩。

安装

cd external/play-go-chess && npx tsc

依赖 Koishi 服务:database + canvaskoishi.yml 中注册 play-go-chess:n7x2k9

指令

开始对局

下棋 围棋           → 创建19路围棋
下棋 围棋 联棋      → 四人联棋 (AC执黑 / BD执白)
下棋 五子棋         → 15路无禁手
下棋 五子棋 有禁手   → 15路有禁手 (黑方禁双三/双四/长连)
下棋 黑白棋         → 8路黑白棋

空棋盘渲染后等待落子。先落子者执黑,不再预设开局者为黑方。

落子 (自动加入)

!A1     → A1位置落子
!J10    → J10位置落子 (围棋坐标跳过字母I)
!Q10    → Q10位置落子

对局者使用 !<坐标> 格式落子(无需指令词)。非对局者发送 !坐标 无响应。裸坐标(不含!)不会被拦截,对局者可在群里正常聊天。首次落子者自动加入对局并执黑,后续落子者依次自动加入。满员后他人落子无响应。联棋四人轮转:A(黑)→B(白)→C(黑)→D(白)。

其他指令

下棋             → 查看帮助(无参数时)
停一手            → 停着 (围棋/黑白棋, 五子棋不允许,也可用于加入对局)
悔棋             → 回退一步
认输             → 认输结束对局
结束对局           → 主动结束对局(等待阶段任何人可用)
查看             → 重新发送当前棋盘图
我的战绩           → 渲染三棋战绩卡片 (深色卡片风)
围棋 帮助          → 围棋详细规则
五子棋 帮助         → 五子棋详细规则
黑白棋 帮助         → 黑白棋详细规则

游戏规则

围棋 (19路)

  • 提子: 落子后移除对方无气棋组
  • 禁着: 不允许自杀 (落子后己方无气)
  • 劫争: 超级劫检测 — 全局棋盘状态不可重复
  • 终局: 双方连续停着 (各pass一次) → 中国数子法计分
  • 计分: 中国数子法,子空皆地(地盘 = 活子数 + 所围空)。黑贴 3.75 子。双活区域不计入任何一方。让子局贴还让子数一半(如让6子贴3子),让先贴 0.5 子
  • 联棋: AC共享黑棋胜负,BD共享白棋胜负

五子棋 (15路)

  • 无禁手: 先形成五连者获胜
  • 有禁手 (MVP): 黑方禁止双三、双四、长连 (>5子)。五连仍然允许。暂仅检测直线连续型棋型,跳活型后续迭代

黑白棋 (8路)

  • 必须在能翻转至少一枚对方棋子的位置落子
  • 双方均无合法着法或棋盘下满时终局
  • 棋子多者获胜;相等为平局

战绩系统

我的战绩 查询数据库渲染 620×380 战绩卡片:

  • 深色渐变背景 + 金色标题
  • 三列展示:围棋、五子棋、黑白棋
  • 每列:符号、总对局、胜/负/和 (绿/红/灰)、胜率进度条
  • 底部总览:总局数、总胜率

每局终了自动更新数据库 (chess_player_stats 表)。

架构

index.ts              注册指令 + !坐标落子中间件
manager.ts            对局管理 (Map<channelId, GameSession>, 落子即加入, 回合管理, 战绩更新)
  ├── renderer.ts        Canvas 渲染 + CJK 字体 + 3种棋盘渲染
  ├── stats-renderer.ts  战绩卡片 Canvas 渲染
  ├── othello-engine.ts  纯函数: getValidMoves / applyMove / 8方向翻转
  ├── gomoku-engine.ts   纯函数: checkWin / isForbiddenMove / 禁手检测
  ├── go-engine.ts       纯函数: getGroup(BFS) / getLiberties / applyMove(提子) / isSuperko / 中国数子法
  └── utils.ts           坐标解析 / 棋盘操作 / 游戏名解析

配置项

| 项 | 默认值 | 说明 | |----|--------|------| | commandStart | 下棋 | 创建对局 / 查看帮助 | | commandPass | 停一手 | 停着(也可用于加入对局) | | commandUndo | 悔棋 | 回退一步 | | commandResign | 认输 | 认输 | | commandEnd | 结束对局 | 主动结束对局 | | commandView | 查看 | 查看当前棋盘 | | commandStats | 我的战绩 | 查看三棋战绩 | | goKomi | 3.75 | 围棋贴子(中国规则) |

棋盘参数

| 棋种 | 路数 | 格子 (px) | 画布 (px) | |------|------|-----------|-----------| | 围棋 | 19×19 | 30 | ~592 | | 五子棋 | 15×15 | 36 | ~556 | | 黑白棋 | 8×8 | 52 | ~416 |

限制与后续

  • 五子棋有禁手 MVP 仅检测直线连续型,跳活型 (如 X_XXX) 待迭代
  • 需运行环境有 CJK 字体或 skia-canvas 自动下载 Noto Sans SC
  • 战绩卡片暂未集成用户头像