Initial scaffold: AI Tycoon monorepo with core game loop

Turborepo monorepo with three packages:
- packages/shared: TypeScript types for all 14 game systems + balance constants + formatting utils
- packages/game-engine: Pure TS simulation engine with tick processor, economy, infrastructure, compute, research, market, and reputation systems
- apps/web: React + Vite + Tailwind + Zustand frontend with sidebar dashboard layout, new game screen, dashboard with charts, infrastructure management, and model training pages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-24 16:53:46 -04:00
commit fdc8e544ae
57 changed files with 4753 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
import { useEffect, useRef } from 'react';
import { GameEngine } from '@ai-tycoon/game-engine';
import { useGameStore } from '@/store';
export function useGameLoop() {
const engineRef = useRef<GameEngine | null>(null);
const companyName = useGameStore((s) => s.meta.companyName);
const gameSpeed = useGameStore((s) => s.meta.gameSpeed);
useEffect(() => {
if (!companyName) return;
const engine = new GameEngine({
getState: () => {
const state = useGameStore.getState();
return {
meta: state.meta,
economy: state.economy,
infrastructure: state.infrastructure,
compute: state.compute,
research: state.research,
models: state.models,
market: state.market,
competitors: state.competitors,
talent: state.talent,
data: state.data,
reputation: state.reputation,
events: state.events,
achievements: state.achievements,
};
},
setState: (partial) => {
useGameStore.getState().updateState(partial);
},
});
engineRef.current = engine;
engine.start();
return () => {
engine.stop();
engineRef.current = null;
};
}, [companyName]);
useEffect(() => {
if (engineRef.current) {
engineRef.current.setSpeed(gameSpeed);
}
}, [gameSpeed]);
}