@gui-chat-plugin/go
v0.1.0
Published
Go (Baduk/Weiqi) game plugin for GUI Chat
Readme
@gui-chat-plugin/go
Go (Baduk/Weiqi) game plugin for GUI Chat applications. Play Go on a 9x9 board against an AI assistant.
Features
- Full Go game implementation on 9x9 board
- Interactive board with clickable intersections
- Stone capture detection and counting
- Territory calculation for scoring
- Game end detection (two consecutive passes)
- Suicide rule enforcement
Installation
yarn add @gui-chat-plugin/goUsage
Vue Integration
// In src/tools/index.ts
import GoPlugin from "@gui-chat-plugin/go/vue";
const pluginList = [
// ... other plugins
GoPlugin,
];
// In src/main.ts
import "@gui-chat-plugin/go/style.css";Core-only Usage
import { executeGo, playGo, TOOL_DEFINITION } from "@gui-chat-plugin/go";
// Start a new game
const result = await executeGo(context, {
action: "new_game",
firstPlayer: "user",
});
// Use the game logic directly
import { playGo } from "@gui-chat-plugin/go";
const state = playGo({
action: "new_game",
playerNames: { B: "user", W: "computer" },
});API
GoArgs
interface GoArgs {
action: "new_game" | "move" | "pass";
col?: number; // 0-8 for move action
row?: number; // 0-8 for move action
board?: Cell[][]; // Current board state
currentSide?: Side; // "B" or "W"
playerNames?: { B: GoPlayerType; W: GoPlayerType };
capturedStones?: { B: number; W: number };
consecutivePasses?: number;
firstPlayer?: GoPlayerType; // "user" or "computer"
}GoState
interface GoState {
board: GoBoard; // 9x9 grid of ".", "B", or "W"
currentSide: Side; // Whose turn is next
playerNames: { B: string; W: string };
capturedStones: { B: number; W: number };
counts: { B: number; W: number; empty: number };
isTerminal: boolean;
winner: Side | "draw" | null;
consecutivePasses: number;
lastAction: { type: "new_game" | "move" | "pass"; ... };
error?: string;
}Development
# Install dependencies
yarn install
# Run demo
yarn dev
# Build
yarn build
# Lint
yarn lintLicense
MIT
