@flare-engine/模拟
连续时间动力学:由Plummer软化而成的正体重力,Verlet / 跳跃相融合,波-包接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相.
安装
bun add @flare-engine/simulation
使用量
import { createNBodySystem, leapfrogInto, createRipplePool } from '@flare-engine/simulation';
const nb = createNBodySystem(16);
nb.add(0, 0, 0, 0, 1000);
nb.add(100, 0, 0, 3.16, 1);
nb.step(0.016, 1, 2);
const rp = createRipplePool(32);
rp.emit(0, 0, 0, 20, 100, 30, 2);
const h = rp.heightAt(100, 0, 1);
斯卡尔字段
由两只乒乓支撑的粗花粉酮/热网 Float32Arrays (施工后为零等分). 分离出 3×3 Box-blur 扩散 +多活性衰变 + 二线分样 + Central-diffection 梯度.
import { createScalarField } from '@flare-engine/simulation';
// 'toroidal' (default, wrapping) or 'clamp' (bounded playfield).
const field = createScalarField(800, 600, 4, 'toroidal');
field.deposit(400, 300, 1.0);
field.step(0.4, 0.97, Infinity); // diffuse + decay (no clamp)
const v = field.sample(390, 300); // bilinear read
const grad = { x: 0, y: 0 };
field.gradient(390, 300, grad); // ∇ for obstacle avoidance / chemotaxis
特务
SoA剂(Jones,2010年),能感知到斯卡尔球场,转向最亮的传感器,移动,并沉淀——发动机的第一个出现-AI原始. 通过注射完全确定性 SeededRNG。 。 。 .
import { SeededRNG } from '@flare-engine/math';
import { createScalarField, createStigmergy, SENSE_DEFAULTS } from '@flare-engine/simulation';
const field = createScalarField(800, 600, 4);
const agents = createStigmergy(field, {
count: 2000,
...SENSE_DEFAULTS,
stepSize: 2,
depositAmount: 1,
chaos: 0.05,
}, new SeededRNG(42));
// Game loop:
field.step(0.4, 0.97, 10);
agents.update();
agents.forEachAgent((x, y) => { /* draw */ });
onSense 编号 : onMove 钩子让呼叫者通过关闭自己的数据(营养源,障碍字段)来注入化疗税或反感,而不会将引擎与域逻辑相接.
见 API 规格。 。 。 .
许可证
阿帕奇 - 2.0