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

@aivoland/game-engine

v0.0.1

Published

Pure TypeScript turn-based game engine with a ruleset architecture. No UI, network, storage, timer, or runtime dependencies.

Downloads

114

Readme

@aivoland/game-engine

Pure TypeScript turn-based game engine with a ruleset architecture. No UI, network, storage, timer, or runtime dependencies.


Rules & Guardrails

  • Never couple this package to React, Vue, DOM, Canvas, HTTP, WebSocket, or any database.
  • Never call Agent/LLM APIs or generate UI text inside ruleset logic.
  • Never let concrete ruleset code touch core concepts, and never let one ruleset depend on another.
  • Do not use class, Map, Set, Date, or functions inside game state objects — state must be plain, serializable objects.
  • Do not introduce randomness inside rule functions; callers must inject seeds or pre-rolled results.
  • Only promote a utility to shared/ when two or more rulesets share it.
  • Run pnpm run check:test before committing any ruleset change.

Core Project Context

  • Package: @aivoland/game-engine — standalone logic library, zero runtime dependencies.
  • Repository root: packages/game-engine/
  • Source layout:
    • src/index.ts — stable public exports only
    • src/core/ — generic interfaces, GameSession, result/error/event base types
    • src/rulesets/<name>/ — one directory per game ruleset
    • src/shared/ — cross-ruleset utilities (geometry.ts, grid.ts, ids.ts)
  • Commands:
    • Lint: pnpm run check:lint
    • Type-check: pnpm run check:type
    • Dependency graph: pnpm run check:dep
    • Test: pnpm run check:test

Architecture Notes

  • IGameRuleset<TState, TAction, TView, TEvent> (src/core/types.ts) — the contract every ruleset must implement:
    • createInitialState(): TState
    • getCurrentActor(state): string
    • getLegalActions(state): TAction[]
    • applyAction(state, action): IApplyActionResult<TState, TEvent>
    • getView(state, actorId): TView
    • isGameOver(state): IGameOverResult | null
  • GameSession (src/core/session.ts) — thin stateful wrapper around a ruleset; holds current state and accumulated event log. Use it as the external drive loop:
    while (!session.isGameOver()) {
      const view = session.getView(session.getCurrentActor());
      const action = await agent.decide(view, session.getLegalActions());
      session.applyAction(action);
    }
  • State rules: plain objects only; no class instances, no Map/Set/Date, no embedded functions. State must be JSON-serializable for replay and branching.
  • Rule functions: pure — take old state + action, return new state + events + feedback. No side effects, no external reads.
  • IApplyActionResult (src/core/result.ts): { state, events, feedback } where feedback carries success, apConsumed, apRemaining, and warnings.
  • IGameOverResult (src/core/result.ts): { winner, scores, reason } where reason is 'turn-limit' | 'elimination'.
  • IGameEvent (src/core/events.ts): base shape { type, globalSlot, turn, actorId } — all ruleset events extend this.
  • IGameError (src/core/errors.ts): { code: 'illegal-action' | 'invalid-action' | 'game-over', message }.

Public Exports (src/index.ts)

export { GameSession } from '~/core/session';
export type { IGameRuleset } from '~/core/types';
export type { IActionFeedback, IApplyActionResult, IGameOverResult } from '~/core/result';
export { resourceClashRuleset } from '~/rulesets/resource-clash';
export type { IResourceClashEvent } from '~/rulesets/resource-clash/events';
export type {
  IEnemyMemory, IFaction, IFactionResources, IOutpost,
  IResourceClashAction, IResourceClashState, IResourceClashView,
  ISourceType, IUnit, IUnitType, IVisibleSource,
} from '~/rulesets/resource-clash/types';

Only export from src/index.ts. Do not import internal modules directly from consuming packages.


Coding Style

  • Language: TypeScript strict. Prefer async/await; avoid void return annotations.
  • Interfaces and types: MUST be prefixed with I (e.g., IUnit, IFaction).
  • File naming: kebab-case only (legal-actions.ts, not legalActions.ts).
  • Tests: co-locate as *.test.ts alongside source; exercise public APIs; no network fixtures.
  • Class methods: arrow functions unless prototype method is required (no MobX stores in this package).

Adding a New Ruleset

  1. Create src/rulesets/<name>/ with: index.ts, constants.ts, types.ts, initial-state.ts, legal-actions.ts, reducer.ts, vision.ts, scoring.ts, events.ts.
  2. Implement IGameRuleset<TState, TAction, TView, TEvent> in index.ts.
  3. Export the ruleset object and all public types from src/index.ts.
  4. Do not import from other rulesets.
  5. Run pnpm run check:dep to verify the dependency graph remains clean.