lgtm
This commit is contained in:
parent
ce383ce34c
commit
d2da0d1617
25 changed files with 531 additions and 1036 deletions
|
|
@ -1,6 +1,11 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { appConfig } from '../config';
|
||||
import { AgentGenerationPipeline } from '../pipelines/agents/agent-generation/agent-generation-pipeline';
|
||||
import { settings } from '../settings';
|
||||
import { AgentPopulation } from './agent-population';
|
||||
|
||||
vi.hoisted(() => {
|
||||
Object.defineProperty(globalThis, 'localStorage', {
|
||||
configurable: true,
|
||||
|
|
@ -11,11 +16,6 @@ vi.hoisted(() => {
|
|||
});
|
||||
});
|
||||
|
||||
import { appConfig } from '../config';
|
||||
import { AgentGenerationPipeline } from '../pipelines/agents/agent-generation/agent-generation-pipeline';
|
||||
import { settings } from '../settings';
|
||||
import { AgentPopulation } from './agent-population';
|
||||
|
||||
const originalAgentBudgetMax = settings.agentBudgetMax;
|
||||
const originalBrushSize = settings.brushSize;
|
||||
const originalSelectedColorIndex = settings.selectedColorIndex;
|
||||
|
|
@ -63,10 +63,35 @@ describe('AgentPopulation adaptive budget', () => {
|
|||
expect(settings.agentBudgetMax).toBeGreaterThan(1_000_000);
|
||||
expect(population.activeAgentCount).toBeGreaterThan(1_000_000);
|
||||
expect(settings.agentBudgetMax).toBeLessThanOrEqual(
|
||||
appConfig.simulation.globalAgentCap
|
||||
appConfig.simulation.budget.adaptiveCapMax
|
||||
);
|
||||
});
|
||||
|
||||
it('does not grow the cap above the adaptive max agent count', () => {
|
||||
const population = createPopulation();
|
||||
const maxAgentCount = appConfig.simulation.budget.adaptiveCapMax;
|
||||
settings.agentBudgetMax = maxAgentCount - 1;
|
||||
setPopulationActiveCount(population, maxAgentCount - 1);
|
||||
|
||||
population.growBudget(1 / 60, 60, 60);
|
||||
population.spawnStrokeAgents(vec2.fromValues(0, 0), vec2.fromValues(16, 0));
|
||||
|
||||
expect(settings.agentBudgetMax).toBe(maxAgentCount);
|
||||
expect(population.activeAgentCount).toBe(maxAgentCount);
|
||||
});
|
||||
|
||||
it('clamps a manually raised cap before adding agents', () => {
|
||||
const population = createPopulation();
|
||||
const maxAgentCount = appConfig.simulation.budget.adaptiveCapMax;
|
||||
settings.agentBudgetMax = maxAgentCount + 1_000;
|
||||
setPopulationActiveCount(population, maxAgentCount);
|
||||
|
||||
population.spawnStrokeAgents(vec2.fromValues(0, 0), vec2.fromValues(16, 0));
|
||||
|
||||
expect(settings.agentBudgetMax).toBe(maxAgentCount);
|
||||
expect(population.activeAgentCount).toBe(maxAgentCount);
|
||||
});
|
||||
|
||||
it('decreases the cap and active count slowly when FPS falls below the threshold', () => {
|
||||
const population = createPopulation();
|
||||
setPopulationActiveCount(population, 1_000_000);
|
||||
|
|
@ -74,8 +99,6 @@ describe('AgentPopulation adaptive budget', () => {
|
|||
population.growBudget(10, 50, 60);
|
||||
|
||||
expect(settings.agentBudgetMax).toBe(appConfig.simulation.budget.adaptiveCapMin);
|
||||
expect(population.activeAgentCount).toBe(
|
||||
appConfig.simulation.budget.adaptiveCapMin
|
||||
);
|
||||
expect(population.activeAgentCount).toBe(appConfig.simulation.budget.adaptiveCapMin);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue