From cb43ebfe831967624e0a6f1783465020814f8fb2 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Wed, 11 Mar 2026 15:14:46 -0400 Subject: [PATCH] Remove food from side-view world initialization --- src/WorldInit.ts | 22 +--------------------- src/__tests__/worldInit.test.ts | 16 ++++++---------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/WorldInit.ts b/src/WorldInit.ts index 34e02d1..8cc86c8 100644 --- a/src/WorldInit.ts +++ b/src/WorldInit.ts @@ -1,4 +1,4 @@ -import { MAT_FOOD, MAT_HOME, MAT_SAND } from "./constants"; +import { MAT_HOME, MAT_SAND } from "./constants"; export function generateSideViewWorld(worldSize: number): Float32Array { const data = new Float32Array(worldSize * worldSize * 4); @@ -19,25 +19,5 @@ export function generateSideViewWorld(worldSize: number): Float32Array { const homeIdx = (surfaceRow * worldSize + centerX) * 4; data[homeIdx] = MAT_HOME; - // scatter food on surface — deterministic spots spread across the row - const foodPositions = [ - Math.floor(worldSize * 0.15), - Math.floor(worldSize * 0.35), - Math.floor(worldSize * 0.65), - Math.floor(worldSize * 0.85), - ]; - for (const fx of foodPositions) { - // place a small cluster (3 cells wide) at each position - for (let dx = -1; dx <= 1; dx++) { - const x = fx + dx; - if (x >= 0 && x < worldSize) { - const idx = (surfaceRow * worldSize + x) * 4; - if (data[idx] !== MAT_HOME) { - data[idx] = MAT_FOOD; - } - } - } - } - return data; } diff --git a/src/__tests__/worldInit.test.ts b/src/__tests__/worldInit.test.ts index 8a8da14..bc82087 100644 --- a/src/__tests__/worldInit.test.ts +++ b/src/__tests__/worldInit.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { MAT_AIR, MAT_FOOD, MAT_HOME, MAT_SAND } from "../constants"; +import { MAT_AIR, MAT_HOME, MAT_SAND } from "../constants"; import { generateSideViewWorld } from "../WorldInit"; const SIZE = 64; @@ -17,9 +17,9 @@ describe("generateSideViewWorld", () => { for (let x = 0; x < SIZE; x++) { const idx = (y * SIZE + x) * 4; const mat = data[idx]; - // home and food are allowed on the surface row + // home is allowed on the surface row if (y === sandHeight - 1) { - expect([MAT_SAND, MAT_HOME, MAT_FOOD]).toContain(mat); + expect([MAT_SAND, MAT_HOME]).toContain(mat); } else { expect(mat).toBe(MAT_SAND); } @@ -74,18 +74,14 @@ describe("generateSideViewWorld", () => { throw new Error("home not on surface row"); }); - test("some cells have R = MAT_FOOD on the surface row", () => { + test("no food placed on the surface row", () => { const data = generateSideViewWorld(SIZE); const surfaceRow = Math.floor(SIZE * 0.6) - 1; - let foodCount = 0; for (let x = 0; x < SIZE; x++) { const idx = (surfaceRow * SIZE + x) * 4; - if (data[idx] === MAT_FOOD) { - foodCount++; - } + const mat = data[idx]; + expect(mat === MAT_SAND || mat === MAT_HOME).toBe(true); } - - expect(foodCount).toBeGreaterThan(0); }); });