You are an expert Systems...
About this model
You are an expert Systems Architect, Game Designer, and Test-Driven Development (TDD) engineer specializing in text-based strategy simulation engines.
### 🎯 GOAL Build a modular, text-based Kingdom Simulator inspired by Age of Empires (AoE) resource economies and the macro-systems of Warsim. The core engine must be mathematically deterministic and designed from day one to scale up infinitely via automated validation pipelines.
### 📐 THE MATHEMATICAL FRAMEWORK The entire world state must be tracked as a strict Vector State Model. 1. Resource Stockpiles Vector: [Food, Wood, Gold, Stone] 2. Worker Allocation Matrix: [Farming_Villagers, Lumberjacks, Miners, Quarrymen, Idle_Villagers] 3. Structural Age State: [Dark_Age, Feudal_Age, Castle_Age, Imperial_Age]
Global Invariant Constraints (The Mathematical Box): - No resource pool can ever drop below zero (Resource_Val = 0). - Total Villagers allocated to tasks must always EQUAL (Total_Villagers - Idle_Villagers). - All modifier inputs from external files/AI additions must apply via linear vector transformations: S_new = S_old + T.
### ⚙️ SYSTEM ARCHITECTURE REQUIREMENTS You must structure the game script into 4 isolated, distinct layers: 1. DATA MODEL LAYER: Stores arrays, structures, dictionaries, and current session parameters. 2. SIMULATION LOGIC ENGINE: Handles resource generation per turn based on allocation math, villager production costs (50 Food), and Age transitions. 3. THE VALIDATION LINTER (CRITIC FEEDBACK LOOP): A runtime screening module that intercepts any data, action, or AI-generated event before it updates the live state. It rejects anything that violates schema structure or causes memory boundaries to breach. 4. AUTOMATED MATRIX TESTING SUITE: A unit testing suite running parallel to execution that simulates 100 turns of aggressive random inputs to find edge-case runtime crashes, hyper-inflation, or division-by-zero math errors.
### 🔄 DETAILED AI SCALING FEEDBACK LOOP LOGIC To allow an AI to safely add hundreds of custom events, buildings, and maps later without writing code, implement a strict JSON structural validation gate inside the code: - Every expansion item must be delivered strictly as an immutable JSON configuration block. - The built-in Linter must mathematically check all input types. If an extension item lists a modifier like "stability": "text_value" or "gold": 9999999, the Linter must immediately catch the data-type error or overflow breach, reject the file injection, and output a detailed debugging diagnostic string.
### 🚀 OUTPUT INSTRUCTIONS 1. Write the complete, single-file framework script implementing this design. 2. Use pure Python 3 or standard JavaScript (Node.js/ES6) with absolutely no external layout dependencies. 3. Write clean, idiomatic code with robust error boundaries. 4. Include a fully functional Main Text User Loop interface alongside the complete Automated Testing verification block at the base of the code.
Begin your implementation now. Provide the clean, well-commented source code without conversational filler.
"You are an expert Systems..." is a public Machinations diagram shared in the Community by bugmenot23423, with 21 components.
It was created in August 2026 and last edited in August 2026.
Open the diagram in the Machinations app and press Play to watch the resources move, adjust its values to test how the system responds, or remix it to make an editable copy in My diagrams.