Replace antsCount with antsStartCount and antBudget config
This commit is contained in:
parent
cd4f10bc80
commit
f5b9af0ccc
4 changed files with 31 additions and 5 deletions
|
|
@ -2,7 +2,9 @@ const STORAGE_KEY = "ants-simulation-config";
|
||||||
|
|
||||||
const defaults = {
|
const defaults = {
|
||||||
worldSize: 1024,
|
worldSize: 1024,
|
||||||
antsCount: 12,
|
antsStartCount: 4,
|
||||||
|
antBudget: 512,
|
||||||
|
seedWorld: true,
|
||||||
simulationStepsPerSecond: 60,
|
simulationStepsPerSecond: 60,
|
||||||
scentThreshold: 0.01,
|
scentThreshold: 0.01,
|
||||||
scentFadeOutFactor: 0.001,
|
scentFadeOutFactor: 0.001,
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,14 @@ class GUIController {
|
||||||
.step(1)
|
.step(1)
|
||||||
.onChange(() => this.saveAndEmit("reset"));
|
.onChange(() => this.saveAndEmit("reset"));
|
||||||
simFolder
|
simFolder
|
||||||
.add(Config, "antsCount", 0, 22)
|
.add(Config, "antsStartCount", 0, 64)
|
||||||
.name("Ants count 2^")
|
.name("Starting ants")
|
||||||
.step(1)
|
.step(1)
|
||||||
.onChange(() => this.saveAndEmit("reset"));
|
.onChange(() => this.saveAndEmit("reset"));
|
||||||
|
simFolder
|
||||||
|
.add(Config, "seedWorld")
|
||||||
|
.name("Seed home + food")
|
||||||
|
.onChange(() => this.saveAndEmit("reset"));
|
||||||
simFolder
|
simFolder
|
||||||
.add(Config, "scentFadeOutFactor", 0, 0.01)
|
.add(Config, "scentFadeOutFactor", 0, 0.01)
|
||||||
.name("Pheromone evaporation factor")
|
.name("Pheromone evaporation factor")
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ export default class Renderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private initResources() {
|
private initResources() {
|
||||||
const antTextureSize = Math.round(Math.sqrt(2 ** Config.antsCount));
|
const antTextureSize = Math.ceil(Math.sqrt(Config.antBudget));
|
||||||
|
|
||||||
this.resources = {
|
this.resources = {
|
||||||
worldRenderTarget: new THREE.WebGLRenderTarget(
|
worldRenderTarget: new THREE.WebGLRenderTarget(
|
||||||
|
|
@ -325,7 +325,7 @@ export default class Renderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public reset(scenes: SceneCollection) {
|
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(
|
this.resources.worldRenderTarget.setSize(
|
||||||
Config.worldSize,
|
Config.worldSize,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
|
import { defaults } from "../Config";
|
||||||
import {
|
import {
|
||||||
MAT_AIR,
|
MAT_AIR,
|
||||||
MAT_DIRT,
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue