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
@@ -0,0 +1,45 @@
import type { GameState, EconomyState, InfrastructureState } from '@ai-tycoon/shared';
import { FINANCIAL_SNAPSHOT_INTERVAL, MAX_FINANCIAL_HISTORY } from '@ai-tycoon/shared';
import type { MarketTickResult } from './marketSystem';
export function processEconomy(
state: GameState,
market: MarketTickResult,
infrastructure: InfrastructureState,
): EconomyState {
const revenue = market.apiRevenue + market.subscriptionRevenue;
const infraExpenses = infrastructure.dataCenters.reduce((sum, dc) => {
return sum + dc.energyCostPerTick + dc.maintenanceCostPerTick;
}, 0);
const talentExpenses = state.talent.totalSalaryPerTick;
const dataExpenses = state.data.partnerships.reduce((sum, p) => sum + p.costPerTick, 0);
const expenses = infraExpenses + talentExpenses + dataExpenses;
const money = state.economy.money + revenue - expenses;
const financialHistory = [...state.economy.financialHistory];
if (state.meta.tickCount % FINANCIAL_SNAPSHOT_INTERVAL === 0) {
financialHistory.push({
tick: state.meta.tickCount,
money,
revenue,
expenses,
valuation: state.economy.funding.valuation,
});
if (financialHistory.length > MAX_FINANCIAL_HISTORY) {
financialHistory.shift();
}
}
return {
...state.economy,
money: Math.max(0, money),
totalRevenue: state.economy.totalRevenue + revenue,
totalExpenses: state.economy.totalExpenses + expenses,
revenuePerTick: revenue,
expensesPerTick: expenses,
financialHistory,
};
}