Add warfare simulation engine with combat modeling and missile tracking#1727
Add warfare simulation engine with combat modeling and missile tracking#1727rsunil92 wants to merge 1 commit intokoala73:mainfrom
Conversation
Introduces a complete turn-based warfare simulation system with: - **8 proto definitions**: military units, combat system (Lanchester equations), missile tracking (launch/trajectory/interception), logistics & supply lines, territorial control, conflict analysis & outcome forecasting, game state - **16 RPC endpoints** via WarfareService: simulation lifecycle, unit operations, combat resolution, missile launch/intercept, supply status, territorial control, capability assessment, casualty projection, outcome scenario analysis - **Core simulation engine**: Haversine-based movement, proximity combat detection, supply consumption, territory dynamics, morale/readiness recovery, auto-conclusion - **4 frontend panels**: WarfareSimulationPanel (main game UI with 6 tabs), MissileTrackerPanel, CasualtyEstimatorPanel, WarfareCorrelationPanel - **Client service**: typed RPC wrappers for all warfare endpoints Covers: unit movement, combat calculations, resource management, battlefield positions, unit compositions, supply lines, missile launch/interception tracking, casualty estimations, military capability assessments, territorial control maps, and conflict outcome forecasting with probability distributions. https://claude.ai/code/session_0157x5y4r6AxJXXGk9pmcheX
|
@claude is attempting to deploy a commit to the Elie Team on Vercel. A member of the Team first needs to authorize it. |
|
This is very cool, I can rework, but I don't have bandwidth tonight, will schedule for next 2-3 days 🔴 P1 — BLOCKS MERGE
api/warfare/v1/[rpc].ts:1 has runtime: 'edge'. But simulation-engine.ts:128 stores all simulation state in a module-level const simulations = new Map<string, SimulationState>(). Vercel Edge functions are stateless and run on globally distributed workers. createSimulation writes to one worker's in-process Map, then getGameState, advanceTurn, and all 14 |
|
@rsunil92 — the P1 issue @koala73 flagged still needs resolution: the simulation uses a module-level Map for state, which is incompatible with stateless Vercel Edge functions. The fix: move simulation state to Upstash Redis (already used in the project). Each RPC would GET/SET simulation state by simulationId: // Instead of: simulations.set(id, state)
await redis.set(`sim:${id}`, JSON.stringify(state), { ex: 3600 });Before investing in the fix though — @koala73, is a turn-based warfare simulation engine in scope for WorldMonitor's roadmap? Worth confirming the direction before a full rewrite. |
Summary
Adds a comprehensive warfare simulation system to WorldMonitor, enabling turn-based conflict modeling with Lanchester's Square Law combat resolution, missile trajectory tracking, supply line logistics, territorial control dynamics, and casualty projections. Includes a full gRPC service definition, in-memory simulation engine, UI panels for scenario control and analysis, and client-side service layer.
Type of change
Affected areas
/api/*)What's included
Core simulation engine (
server/worldmonitor/warfare/v1/simulation-engine.ts)Service layer
proto/worldmonitor/warfare/v1/): 16 RPCs covering simulation lifecycle, unit operations, missile tracking, logistics, territorial control, and analysisserver/worldmonitor/warfare/v1/handler.ts): Implements all RPC endpointssrc/generated/server/worldmonitor/warfare/v1/service_server.ts): TypeScript interfaces for all messages and enumssrc/services/warfare-simulation.ts): Typed RPC wrappers with local state cachingUI components
Proto definitions
military_unit.proto: Unit types, states, and compositioncombat_system.proto: Combat engagement, outcomes, and terrain modifiersmissile_tracking.proto: Missile systems, launches, trajectories, and interceptionlogistics.proto: Supply lines, resource pools, and supply typesterritorial_control.proto: Territory ownership, frontlines, and control trendsconflict_analysis.proto: Capability assessments and casualty projectionsgame_state.proto: Simulation lifecycle and turn managementKey features
Checklist
Testing
The simulation engine is self-contained with deterministic initialization. Manual testing via the UI panels will verify:
https://claude.ai/code/session_0157x5y4r6AxJXXGk9pmcheX