Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/game-api/src/experiment-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
experimentExportRequestSchema,
experimentMetricsSchema,
PERSONALITY_PROFILES,
NEUTRAL_AGENT_COLOR,
STRATEGY_PROFILES,
type Agent,
type AgentId,
Expand Down Expand Up @@ -875,7 +876,7 @@ function currentTerritory(world: WorldSnapshot, agents: readonly Agent[]) {
name,
color,
allianceId: alliance?.id ?? null,
effectiveColor: alliance?.color ?? color,
effectiveColor: alliance?.color ?? NEUTRAL_AGENT_COLOR,
controlledCellCount: counts.get(id) ?? 0,
};
});
Expand Down
45 changes: 40 additions & 5 deletions apps/game-api/src/simulation-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import {
AGENT_DECISION_CONTRACT_VERSION,
ALLIANCE_COLOR_PALETTE,
NEUTRAL_AGENT_COLOR,
PERSONALITY_MAX_LENGTH,
PATIENT_ZERO_DIPLOMACY_SUMMARY_LIMITS,
assignBehavior,
Expand Down Expand Up @@ -1542,11 +1543,16 @@ describe('SimulationService', () => {
},
diplomacy:
observation.agentId === emberId
? { type: 'propose-alliance', recipientId: rookId! }
: {
type: 'accept-alliance',
proposalId: observation.inboundAllianceProposals[0]!.id,
},
? observation.actingAllianceId
? { type: 'leave-alliance' }
: { type: 'propose-alliance', recipientId: rookId! }
: observation.agentId === rookId &&
observation.inboundAllianceProposals[0]
? {
type: 'accept-alliance',
proposalId: observation.inboundAllianceProposals[0].id,
}
: undefined,
summary: 'Exercise all independent components.',
},
metadata: {
Expand All @@ -1559,6 +1565,11 @@ describe('SimulationService', () => {
},
};
const simulation = service(provider);
expect(
simulation
.generateExperimentExport(exportRequest('minimal'))
.currentTerritory?.map(({ effectiveColor }) => effectiveColor),
).toEqual(DEVELOPMENT_AGENT_BLUEPRINTS.map(() => NEUTRAL_AGENT_COLOR));
const proposed = await simulation.executeNextTurn();
const formed = await simulation.executeNextTurn();
expect(proposed).toMatchObject({
Expand All @@ -1584,12 +1595,36 @@ describe('SimulationService', () => {
.slice(0, 2)
.map(({ effectiveColor }) => effectiveColor),
).toEqual(['#0072B2', '#0072B2']);
expect(
simulation
.generateExperimentExport(exportRequest('minimal'))
.currentTerritory?.slice(0, 3)
.map(({ effectiveColor }) => effectiveColor),
).toEqual(['#0072B2', '#0072B2', NEUTRAL_AGENT_COLOR]);
expect(formed.observation.inboundAllianceProposals).toHaveLength(1);
expect(snapshot.experiment.metrics.aggregate).toMatchObject({
proposalsCreated: 1,
alliancesFormed: 1,
alliancesJoined: 2,
});
for (let index = 0; index < 6; index += 1)
await simulation.executeNextTurn();
const left = await simulation.executeNextTurn();
expect(left).toMatchObject({
diplomacyResult: {
accepted: true,
events: expect.arrayContaining([
expect.objectContaining({ type: 'agent-left-alliance' }),
expect.objectContaining({ type: 'alliance-dissolved' }),
]),
},
});
expect(
simulation
.generateExperimentExport(exportRequest('minimal'))
.currentTerritory?.slice(0, 2)
.map(({ effectiveColor }) => effectiveColor),
).toEqual([NEUTRAL_AGENT_COLOR, NEUTRAL_AGENT_COLOR]);
});

it('keeps an exact eight-agent round robin through 200 completed turns', async () => {
Expand Down
1 change: 1 addition & 0 deletions apps/world-lab/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
allowedDevOrigins: ['127.0.0.1'],
devIndicators: false,
transpilePackages: ['@hexzero/shared', '@hexzero/world-engine'],
experimental: { useTypeScriptCli: false },
async rewrites() {
Expand Down
17 changes: 0 additions & 17 deletions apps/world-lab/src/app/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -933,29 +933,12 @@ h2 {
gap: 5px;
margin-bottom: 5px;
}
.follow-turn-toggle {
display: flex;
align-items: center;
gap: 7px;
padding: 3px 6px;
color: #b9c8c3;
font-size: 0.72rem;
}
.agent-row-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 6px;
}
.turn-indicator {
padding: 1px 5px;
border: 1px solid #557168;
border-radius: 999px;
color: #bfe8d0;
font-size: 0.6rem;
font-weight: 700;
text-transform: uppercase;
}
.agent-roster button {
width: 100%;
padding: 6px;
Expand Down
Loading
Loading