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

jungo

v0.2.0

Published

A Jungo game library

Readme

CI npm version

API Documentation

jungo

純碁(Jungo)のゲームロジックを提供するTypeScriptライブラリです。

概要

純碁は、盤上の石数のみで勝敗を決めるシンプルな囲碁です。このライブラリは、純碁のゲームロジックをTypeScriptで実装し、イミュータブルなAPIを提供します。

特徴

  • イミュータブルな設計: 全てのゲーム状態は不変(immutable)で、各着手は新しい状態を返します
  • 完全な型定義: TypeScriptによる完全な型サポート
  • 純粋な関数: 副作用のない純粋関数によるゲームロジック

インストール

npm install jungo

基本的な使い方

import { createGame, playMove } from 'jungo';

// 9x9の盤面でゲームを開始
const initialState = createGame(9);

// 黒が(2, 3)に着手
const result1 = playMove(initialState, {
  type: 'play',
  position: { x: 2, y: 3 }
});

if (result1.success) {
  console.log('着手成功');
  const newState = result1.state;
  
  // 白が(3, 3)に着手
  const result2 = playMove(newState, {
    type: 'play',
    position: { x: 3, y: 3 }
  });
  
  if (result2.success) {
    console.log('白の着手成功');
  }
}

// パス
const passResult = playMove(initialState, { type: 'pass' });

// 投了
const resignResult = playMove(initialState, { type: 'resign' });

API仕様

createGame(size: number): GameState

新しいゲームを作成します。

パラメータ:

  • size: 盤面のサイズ(例: 5, 7, 9)

戻り値:

  • 初期化されたGameStateオブジェクト

playMove(state: GameState, move: Move): MoveResult

着手を実行し、新しいゲーム状態を返します。

パラメータ:

  • state: 現在のゲーム状態
  • move: 実行する着手(playpassresignのいずれか)

戻り値:

  • MoveResult: 成功時は新しいGameState、失敗時はエラー情報を含むオブジェクト

着手のタイプ:

// 石を置く
{ type: 'play', position: { x: number, y: number } }

// パス
{ type: 'pass' }

// 投了
{ type: 'resign' }

エラーの種類:

  • invalid_position: 盤面外の座標
  • occupied: すでに石が置かれている
  • suicide: 自殺手(置いた瞬間に取られる手)
  • ko: コウルール違反
  • game_over: ゲーム終了済み

型定義

主要な型:Color, Cell, Position, Move, GameState, MoveResult, MoveError

詳細はAPIドキュメントを参照してください。

純碁のゲームルール

  1. 手番: 黒から始まり、交互に着手します
  2. 石の取り: 相手の石を囲うと取れます
  3. 自殺手禁止: 囲まれている場所に石を置くことはできません。ただし、その手で相手の石を取る場合は置くことができます
  4. コウ: 直前の局面を繰り返す手は打てません
  5. 終局: 2連続パスでゲーム終了
  6. 勝敗: 盤上の石数が多い方の勝ち

開発

# ビルド
npm run build

# テスト実行
npm test

# リント
npm run lint

# フォーマット
npm run format

# 型チェック
npm run typecheck

ライセンス

MITライセンス

Todo

TODO.md