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

@ai-rpg-engine/rumor-system

v2.0.6

Published

Rumor lifecycle engine with mutation mechanics, spread tracking, and faction uptake for AI RPG Engine

Readme

@ai-rpg-engine/rumor-system

npm License: MIT

用于 AI RPG Engine 的传言生命周期引擎,具有变异机制、传播追踪和派系影响功能。

安装

npm install @ai-rpg-engine/rumor-system

功能

传言在传播过程中会发生变异。例如,“玩家杀了一个商人”可能会在经过几轮恐慌的守卫传播后变成“玩家屠杀了五个商人”。该引擎会跟踪可信度衰减、情感强度、传播路径、变异次数以及派系影响,使 NPC 的八卦成为一个模拟系统,而不是简单的复制粘贴。

用法

创建和传播传言

import { RumorEngine } from '@ai-rpg-engine/rumor-system';

const engine = new RumorEngine();

// A guard witnesses a killing
const rumor = engine.create({
  claim: 'player killed merchant_1',
  subject: 'player',
  key: 'killed_merchant',
  value: true,
  sourceId: 'guard_1',
  originTick: 42,
  confidence: 0.9,
  emotionalCharge: -0.7,
});

// The rumor spreads — mutations may apply
const spread = engine.spread(rumor.id, {
  spreaderId: 'guard_1',
  spreaderFactionId: 'town_guard',
  receiverId: 'guard_2',
  receiverFactionId: 'town_guard',
  environmentInstability: 0.3,
  hopCount: 1,
});

// Track which factions absorbed the rumor
engine.recordFactionUptake(rumor.id, 'town_guard');

变异规则

在每次传播过程中,有五个内置的变异规则会以概率触发:

| 变异类型 | 概率 | 效果 | |----------|------------|--------| | exaggerate | 15% | 数值增加 20-50% | | minimize | 10% | 数值减少 | | invert | 5% | 布尔值翻转(罕见,效果显著) | | attribute-shift | 8% | 归属者更改为传播者 | | embellish | 20% | 情感强度加剧 |

环境不稳定会使所有概率倍增。

传言生命周期

spreading → established → fading → dead
  • spreading(传播中):正在在实体之间传递。
  • established(已建立):已达到最大传播次数,广为人知。
  • fading(逐渐消失):在 fadingThreshold 周期内没有新的传播。
  • dead(已失效):在 deathThreshold 周期内没有活动。
// Update lifecycle statuses
engine.tick(currentTick);

// Query active rumors
const activeRumors = engine.query({ status: 'spreading', minConfidence: 0.5 });
const playerRumors = engine.aboutSubject('player');

配置

const engine = new RumorEngine({
  maxHops: 5,              // Transitions to 'established' after this
  confidenceDecayPerHop: 0.1,
  fadingThreshold: 10,     // Ticks inactive → 'fading'
  deathThreshold: 30,      // Ticks inactive → 'dead'
  mutations: customRules,  // Replace default mutations
});

自定义变异规则

import type { MutationRule } from '@ai-rpg-engine/rumor-system';

const panicMutation: MutationRule = {
  id: 'panic',
  type: 'exaggerate',
  probability: 0.30,
  apply: (rumor, ctx) => ({
    ...rumor,
    emotionalCharge: Math.max(-1, rumor.emotionalCharge - 0.3),
    mutationCount: rumor.mutationCount + 1,
  }),
};

序列化

RumorEngine 支持 serialize()RumorEngine.deserialize() 方法,用于持久化数据。

AI RPG Engine 的一部分

此包是 AI RPG Engine 单一代码仓库的一部分。它可以独立使用,也可以与引擎的认知和派系系统集成。

许可证

MIT