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

@quest-editor/ai

v0.1.0

Published

Monster movement AI for HeroQuest — per-type behavior + pathfinding. **Pure and engine-agnostic**: no React, no DB, no rendering, no `Math.random`. It talks only to a small `BoardQuery` port that each consumer implements, and takes an injected seeded RNG,

Downloads

176

Readme

@quest-editor/ai

Monster movement AI for HeroQuest — per-type behavior + pathfinding. Pure and engine-agnostic: no React, no DB, no rendering, no Math.random. It talks only to a small BoardQuery port that each consumer implements, and takes an injected seeded RNG, so the same code drives the tracker (suggested moves) and the future online game (authoritative, replayable). Design: ../../docs/monster-ai.md.

Status

  • Pathfinding (milestone 1): distanceField, stepToward, aStar, reachableFrom.
  • Behavior (milestone 2): decideMonsterTurn — per-type policies (Mind = AI tier), target selection, approach, attack, and flee.
  • ⬜ Coordination (allies focus-fire), ranged/spell intents — later.

The port

Implement BoardQuery over your board state (the tracker maps it from a live session's board_state + revealed fog; the online game from its authoritative state):

interface BoardQuery {
  readonly width: number
  readonly height: number
  passable(t: Tile): boolean            // enterable terrain (not void/rock)
  occupant(t: Tile): 'hero' | 'monster' | null
  blockedEdge(a: Tile, b: Tile): boolean // wall or closed/unrevealed door between adjacent tiles
  lineOfSight(a: Tile, b: Tile): boolean // ranged/visibility (unused by pathfinding)
}

Pathfinding

import { distanceField, stepToward, makeRng } from '@quest-editor/ai'

const rng = makeRng(seed)
// One multi-source pass from the heroes → cost-to-nearest-hero for every tile:
const field = distanceField(board, heroes /* Tile[] */)
// Each monster descends the field within its movement budget (no per-agent search):
const path = stepToward(board, field, monster.pos, MONSTER_STATS[subtype].movement, rng)
  • Why a distance field, not per-monster A*: the grid is tiny (~500 tiles) and many monsters share one goal set (the heroes). Computing the field once and letting every monster read it is O(tiles) + O(budget) per monster — strictly cheaper than N separate searches, and it yields nearest-hero + direction + reachability for free.
  • Opportunity Attack: a monster may path through a hero's square (never end on it). Passing costs DEFAULT_HERO_PASS_COST extra, so routes detour around heroes when cheap but flood through when that's the only way in — the chokepoint fix from heroquest-rules.
  • Determinism: stable neighbor order + index tie-breaks; the injected RNG only breaks ties between equally-good steps. Same inputs + seed ⇒ identical paths.
  • Recompute the field each Zargon turn (state changes); it's cheap.

aStar(board, from, to) is a fallback for "path to this exact empty tile" when a behavior picks a specific destination.

Behavior

import { decideMonsterTurn } from '@quest-editor/ai'

// Per Zargon turn, for each living monster (recompute as the board changes):
const decisions = decideMonsterTurn({
  self: { id, pos, subtype: 'goblin', body },     // body = current
  heroes: [{ id, pos, subtype, body, threat }],   // threat = danger score (e.g. attack dice)
  board,
  rng,
  // stats?: { movement, mind, body }  ← pass core's MONSTER_STATS to be authoritative
})
// → [{ kind:'move', path, to }, { kind:'attack', targetId, from }] | [{ kind:'wait' }]
  • Mind = AI tier: 0 mindless (skeleton/zombie/mummy → nearest hero), 1-2 instinct (orc aggressive; goblin = opportunistic coward), 3-4 tactical (fimir/chaos/gargoyle → highest-threat target, retreat when wounded/surrounded).
  • Stats come from a built-in table mirroring @quest-editor/core (so the package is dependency-free); pass stats to override with the canonical values.
  • Decisions are serializable intents — the app resolves combat and applies movement. The tracker renders them as suggestions; the online server applies them authoritatively.