Replace antsCount with antsStartCount and antBudget config

This commit is contained in:
Jared Miller 2026-03-11 20:45:31 -04:00
parent cd4f10bc80
commit f5b9af0ccc
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
4 changed files with 31 additions and 5 deletions

View file

@ -2,7 +2,9 @@ const STORAGE_KEY = "ants-simulation-config";
const defaults = {
worldSize: 1024,
antsCount: 12,
antsStartCount: 4,
antBudget: 512,
seedWorld: true,
simulationStepsPerSecond: 60,
scentThreshold: 0.01,
scentFadeOutFactor: 0.001,

View file

@ -26,10 +26,14 @@ class GUIController {
.step(1)
.onChange(() => this.saveAndEmit("reset"));
simFolder
.add(Config, "antsCount", 0, 22)
.name("Ants count 2^")
.add(Config, "antsStartCount", 0, 64)
.name("Starting ants")
.step(1)
.onChange(() => this.saveAndEmit("reset"));
simFolder
.add(Config, "seedWorld")
.name("Seed home + food")
.onChange(() => this.saveAndEmit("reset"));
simFolder
.add(Config, "scentFadeOutFactor", 0, 0.01)
.name("Pheromone evaporation factor")

View file

@ -72,7 +72,7 @@ export default class Renderer {
}
private initResources() {
const antTextureSize = Math.round(Math.sqrt(2 ** Config.antsCount));
const antTextureSize = Math.ceil(Math.sqrt(Config.antBudget));
this.resources = {
worldRenderTarget: new THREE.WebGLRenderTarget(
@ -325,7 +325,7 @@ export default class Renderer {
}
public reset(scenes: SceneCollection) {
const antTextureSize = Math.round(Math.sqrt(2 ** Config.antsCount));
const antTextureSize = Math.ceil(Math.sqrt(Config.antBudget));
this.resources.worldRenderTarget.setSize(
Config.worldSize,

View file

@ -1,4 +1,5 @@
import { describe, expect, test } from "bun:test";
import { defaults } from "../Config";
import {
MAT_AIR,
MAT_DIRT,
@ -31,3 +32,22 @@ describe("material ID constants", () => {
}
});
});
describe("config defaults", () => {
test("antsStartCount is a direct count, not an exponent", () => {
expect(defaults.antsStartCount).toBe(4);
expect(defaults.antsStartCount).toBeLessThanOrEqual(64);
});
test("antBudget determines texture pool size", () => {
expect(defaults.antBudget).toBe(512);
});
test("seedWorld defaults to true", () => {
expect(defaults.seedWorld).toBe(true);
});
test("old antsCount key does not exist", () => {
expect("antsCount" in defaults).toBe(false);
});
});