personalitygen
v0.4.2
Published
Generate simulated character personalities for games, stories, and simulations.
Maintainers
Readme
personalitygen for TypeScript
Generate simulated character personalities for games, stories, and simulations using the Big Five (OCEAN) and Adaptive Bifurcated Big Five (ABBF) models.
The package is dependency-free, ESM-only, browser/bundler friendly, and ships JavaScript plus TypeScript declarations. CI tests the current Node.js LTS and latest release lines.
Install
npm install personalitygenGenerate a character
import {
AdaptiveBifurcatedProfile,
BigFivePersonality,
LifeStage,
} from "personalitygen";
const personality = BigFivePersonality.random(LifeStage.Adult);
const adaptive = AdaptiveBifurcatedProfile.fromBigFive(
personality.traits,
);
console.log(personality.conflictResolution.style);
console.log(adaptive.vector);
console.log(adaptive.dominantPoles(0.25));Random factories use Math.random by default. Supply any structural random
source when a game or simulation owns randomness:
const rng = {
uniform(minimum: number, maximum: number): number {
return minimum + (maximum - minimum) * mySeededRandom();
},
};
const personality = BigFivePersonality.random(LifeStage.Adult, { rng });uniform(minimum, maximum) may return either inclusive endpoint and must
return a finite value inside the requested range; malformed results raise
RangeError. A caller-owned seeded source makes a fixed sequence reproducible
within one package version. Outputs from the same integer seed are not
guaranteed to remain identical after a later model or algorithm change.
Models
BigFiveTraitsgroups the five OCEAN trait value objects.BigFiveConflictResolutionrecords a style and its derived concern priorities.BigFivePersonalitycombinesBigFiveTraitswithBigFiveConflictResolution.AdaptiveBifurcatedProfilerepresents the signed ABBF vector in canonical order: order, chaos, cooperation, conflict, competition.- All exported model instances and enum-like value objects are frozen.
- Numeric constructors throw
RangeErrorfor invalid ranges; categorical constructors throwTypeErrorfor unsupported values.
See the repository documentation for the behavioral specification, Python peer, examples, and contribution guidance.
