Give every agent a distinct procedural pixel identity

Replace the single cloned character with identity-derived sprites: skin
tone, hair style and color, outfit (tee/hoodie/blazer), shirt palette, and
glasses all hash off the agent id, drawn with facing-aware variants, a walk
cycle, and carried-item support for later behaviors. The CEO always wears
the blazer. Appearance determinism and population variety are unit-tested.
This commit is contained in:
ZacharyZhang-NY committed 2026-07-06 21:44:04 -04:00
1 parent cab4e4ba33
commit e6532713b5
5 files changed
+338 -46

No files matched your search

@@ -0,0 +1,30 @@
import { describe, expect, test } from "vitest";
import { appearanceFor } from "../../src/renderer/src/pages/office/sprites";
describe("office sprite appearances", () => {
test("identity is deterministic", () => {
const first = appearanceFor("agent-42", false);
const second = appearanceFor("agent-42", false);
expect(second).toEqual(first);
});
test("a team of agents does not look like clones", () => {
const ids = Array.from({ length: 40 }, (_, i) => `agent-${i}-${i * 7919}`);
const looks = ids.map((id) => appearanceFor(id, false));
const skins = new Set(looks.map((look) => look.skin));
const hairStyles = new Set(looks.map((look) => look.hairStyle));
const hairColors = new Set(looks.map((look) => look.hair));
const shirts = new Set(looks.map((look) => look.shirt));
expect(skins.size).toBeGreaterThanOrEqual(4);
expect(hairStyles.size).toBeGreaterThanOrEqual(5);
expect(hairColors.size).toBeGreaterThanOrEqual(5);
expect(shirts.size).toBeGreaterThanOrEqual(6);
expect(looks.some((look) => look.glasses)).toBe(true);
expect(looks.some((look) => !look.glasses)).toBe(true);
});
test("the CEO always dresses the part", () => {
const ceo = appearanceFor("ceo-agent", true);
expect(ceo.outfit).toBe("blazer");
});
});