How mehereen-1/fusion-fields works
Purpose and Entrypoints
Color Wars is a desktop chain-reaction strategy game built as a React/TypeScript frontend packaged by Tauri. The browser UI mounts from src/main.tsx into the application root, with top-level screen/state orchestration in src/App.tsx. Native startup and Tauri integration are in src-tauri/src/main.rs and src-tauri/src/lib.rs.
Game UI and Navigation
The React application presents game, menu, start, results, AI/minimax, experiment, and trace views. src/App.tsx selects or coordinates screens; src/GameBoard.tsx renders the interactive board and src/Cell.tsx represents individual board positions. Supporting flows include src/MenuScreen.tsx, src/StartScreen.tsx, src/ResultScreen.tsx, and src/MinimaxScreen.tsx.
Core Game State and Rules
The game domain is defined in src/types.ts and updated through src/gameLogic.ts. Board interactions flow from cells/board UI into game-logic transitions, which determine legal placement, ownership, chain reactions, turn changes, and game outcome. This is the main boundary between React rendering and game-rule computation:
• src/GameBoard.tsx
• src/Cell.tsx
• src/gameLogic.ts
• src/types.ts
AI Decision Engines
The frontend contains two move-selection approaches. A minimax engine chooses search-based moves via src/minimax/chooseMinimaxMove.ts, exposed through src/minimax/index.ts; its UI is represented by src/MinimaxScreen.tsx. A fuzzy-logic engine derives board features, membership values, rules, and a move choice through:
• src/fuzzy/features.ts
• src/fuzzy/membership.ts
• src/fuzzy/rules.ts
• src/fuzzy/chooseFuzzyMove.ts
Experimentation and Decision Tracing
Experiment workflows are separated from ordinary gameplay in src/ExperimentPanel.tsx and src/experiment.ts. AI/game decision history is modeled or recorded in src/decisionTrace.ts, displayed through src/TraceModal.tsx, and exported by src/traceExporter.ts. This forms a diagnostic/reporting boundary around the decision engines rather than embedding analysis directly in board rendering.
Python Algorithm Reference/Alternate Implementation
A separate Python package implements board mechanics, explosions, evaluation, and minimax, likely for algorithm experimentation or comparison rather than the packaged React runtime. Its executable/module entry is algorithms/main.py; core stages reside in:
• algorithms/board.py
• algorithms/explosion.py
• algorithms/evaluation.py
• algorithms/minimax.py
Python dependencies are isolated in algorithms/requirements.txt.
Runtime and Packaging Boundaries
The frontend uses the Vite/React TypeScript runtime, configured by vite.config.ts and rooted at index.html. Tauri packages that web frontend into a native application using Rust manifests/configuration in src-tauri/Cargo.toml and src-tauri/tauri.conf.json. Tauri capability permissions are explicitly defined in src-tauri/capabilities/default.json. No backend service, database, or network integration is indicated by the repository structure.
Main entry points: App.tsx App coordinator · gameLogic.ts Game rules · GameBoard.tsx Game board · ExperimentPanel.tsx Experiment workflow
Components 20
React game client
- Vite web entry
index.html - React mount
src/main.tsx - App coordinator · Selects and coordinates application views and state.
src/App.tsx - Game board
src/GameBoard.tsx - Board cell
src/Cell.tsx - Game flow screens · Menu, start, result, and minimax views.
src/MenuScreen.tsx - Game domain model
src/types.ts - Game rules · Applies placements, reactions, turns, and outcomes.
src/gameLogic.ts
AI and analysis
- Minimax engine · Publicly exposed through src/minimax/index.ts.
src/minimax/chooseMinimaxMove.ts - Fuzzy board features
src/fuzzy/features.ts - Fuzzy membership
src/fuzzy/membership.ts - Fuzzy rules
src/fuzzy/rules.ts - Fuzzy move chooser
src/fuzzy/chooseFuzzyMove.ts - Experiment workflow
src/ExperimentPanel.tsx - Decision tracing · Displayed by TraceModal and exported by traceExporter.
src/decisionTrace.ts
Native packaging
- Tauri host · Starts and integrates the packaged application.
src-tauri/src/main.rs
Python reference
Separate algorithm implementation for experimentation or comparison.
- Python algorithm entry
algorithms/main.py - Python board mechanics
algorithms/board.py - Python evaluation
algorithms/evaluation.py - Python minimax
algorithms/minimax.py
Connections 23
- Vite web entry → React mount: loads
- React mount → App coordinator: mounts
- App coordinator → Game board: renders gameplay
- App coordinator → Game flow screens: coordinates
- App coordinator → Experiment workflow: opens analysis
- App coordinator → Decision tracing: opens trace
- Game board → Board cell: renders cells
- Board cell → Game rules: submits move
- Game board → Game rules: reads and updates state
- Game rules → Game domain model: uses model
- Game flow screens → Minimax engine: requests move
- Minimax engine → Game rules: evaluates transitions
- Fuzzy board features → Fuzzy membership: feeds values
- Fuzzy membership → Fuzzy rules: provides memberships
- Fuzzy rules → Fuzzy move chooser: drives choice
- Fuzzy move chooser → Game rules: selects legal move
- Experiment workflow → Fuzzy move chooser: runs experiments
- Experiment workflow → Decision tracing: records decisions
- Tauri host → Vite web entry: packages frontend
- Python algorithm entry → Python board mechanics: runs mechanics
- Python algorithm entry → Python minimax: runs search
- Python minimax → Python evaluation: scores positions
- Python minimax → Python board mechanics: simulates moves