Breed. Train. Coordinate. A gamified multi-agent system with constraint-based puzzles.
๐ Play Now: constraint-theory-web.pages.dev
A gamified AI ecosystem where you breed, train, and coordinate AI agents through constraint-based puzzles. Built on Constraint Theory for exact geometric positioning and deterministic agent coordination.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ ๐ฎ Traditional AI: "Configure temperature to 0.7..." โ
โ (Hours of trial and error) โ
โ โ
โ ๐ Constraint Ranch: Start with 3 chickens โ
โ Solve puzzles, unlock species โ
โ Learn AI by playing! โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Prerequisites: Node.js 18+, npm 9+
# Clone and play
git clone https://github.com/SuperInstance/constraint-ranch.git
cd constraint-ranch
npm install && npm run dev
# Open http://localhost:3000
# Your ranch awaits! ๐ค Or play online: constraint-theory-web.pages.dev
Troubleshooting:
# Port 3000 in use?
npm run dev -- --port 3001
# npm install failing?
rm -rf node_modules package-lock.json && npm installโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ YOUR RANCH โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ 1. ๐ฃ HATCH agents from eggs โ
โ 2. ๐งฉ SOLVE puzzles to earn experience โ
โ 3. ๐งฌ BREED agents with desired traits โ
โ 4. ๐ COMPETE on leaderboards โ
โ 5. ๐ EXPORT agents to production โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Screenshot: Main ranch view with agent collection and puzzle selection (see assets/screenshots)
| Species | Size | Specialty | Unlock Level | Tier |
|---|---|---|---|---|
| ๐ Chicken | 5MB | Monitoring, Alerts | 1 (Starter) | Starter |
| ๐ฆ Duck | 100MB | API, Network | 5 | Network |
| ๐ Goat | 150MB | Debug, Navigation | 10 | Network |
| ๐ Sheep | 50MB | Consensus Voting | 15 | Network |
| ๐ Cattle | 500MB | Heavy Reasoning | 20 | Heavy |
| ๐ด Horse | 200MB | Pipeline ETL | 25 | Heavy |
| ๐ฆ Falcon | 5MB | Multi-node Sync | 30 | Specialty |
| ๐ Hog | 10MB | Hardware GPIO | 35 | Specialty |
๐ See Agent Species Documentation for detailed trait ranges, breeding compatibility, and strategy tips for each species.
Position agents optimally using exact geometric coordinates:
Goal: Place 5 agents such that:
โโโ Max distance between any two โค 100 units
โโโ Each agent covers unique monitoring zone
โโโ Total coverage โฅ 95% of map
Solution: Dodecet-encoded positions guarantee exact placement
Key Constraints: max-distance, min-coverage, agent-count, on-perimeter, even-spacing
Route tasks to correct agents using constraint satisfaction:
Incoming: 1000 tasks/minute
โโโ Email tasks โ Cattle agents
โโโ API calls โ Duck agents
โโโ Alerts โ Chicken agents
โโโ Constraint: No agent exceeds 80% capacity
Key Constraints: max-capacity, all-tasks-routed, optimal-routing, max-latency
Create agents with specific trait combinations:
Target: Agent with {polite: 0.9, concise: 0.7, technical: 0.5}
โโโ Parent A: {polite: 0.8, concise: 0.4, technical: 0.9}
โโโ Parent B: {polite: 1.0, concise: 0.9, technical: 0.1}
โโโ Breed strategy: Select gene weights for target
Key Constraints: trait-threshold, trait-match, generations, trait-exceeds-parents
Multi-agent collaboration and consensus:
Task: Complete distributed computation
โโโ 5 Sheep agents for voting consensus
โโโ 1 Falcon for synchronization
โโโ Constraint: Achieve quorum within 60 seconds
Key Constraints: all-tasks-complete, sync-required, leader-designated, no-collision
Complex multi-stage challenges combining all mechanics:
Challenge: Build a production-ready agent system
โโโ Stage 1: Spatial placement (coverage)
โโโ Stage 2: Routing configuration (load balancing)
โโโ Stage 3: Breeding optimization (traits)
โโโ Constraint: Complete all stages perfectly
Key Constraints: complete-all-subpuzzles, resource-limit, perfect-chain
๐ See Puzzle Format Specification for complete constraint types and puzzle definitions.
| Rating | Name | Target Time | XP Range | Example Puzzles |
|---|---|---|---|---|
| โญ | Tutorial | 1-2 min | 100-150 | Coverage basics |
| โญโญ | Beginner | 2-5 min | 150-200 | Triangle formation |
| โญโญโญ | Intermediate | 5-10 min | 200-300 | Load balancing |
| โญโญโญโญ | Advanced | 10-20 min | 300-400 | Multi-region routing |
| โญโญโญโญโญ | Expert | 20+ min | 400-500 | Distributed consensus |
Traditional game AI uses floating-point math, leading to:
Agent A position: (100.0000001, 50.0000002)
Agent B position: (100.0000000, 50.0000000)
Distance: 0.0000002... or is it 0?
Collision detection: "Maybe?"
Constraint Ranch uses exact arithmetic:
Agent A: Dodecet(3, 4, 5, N) // Exact position
Agent B: Dodecet(3, 4, 5, NE) // Exact position
Distance: Exactly โ2 units
Collision: NO (deterministic)
Every puzzle has ONE correct answer. No floating-point ambiguity.
| Level | Title | Unlocks | XP Required |
|---|---|---|---|
| 1-4 | Ranch Hand | ๐ Chickens, Basic puzzles | 0 - 1,000 |
| 5-9 | Drover | ๐ฆ Ducks, Routing puzzles | 1,000 - 5,000 |
| 10-14 | Trail Boss | ๐ Goats, Debug tools | 5,000 - 15,000 |
| 15-19 | Wrangler | ๐ Sheep, Consensus puzzles | 15,000 - 30,000 |
| 20-24 | Rancher | ๐ Cattle, Heavy reasoning | 30,000 - 50,000 |
| 25-29 | Overseer | ๐ด Horses, Pipeline automation | 50,000 - 80,000 |
| 30-34 | Trailblazer | ๐ฆ Falcons, Multi-node sync | 80,000 - 120,000 |
| 35+ | Ranch Master | All species, Night School breeding | 120,000+ |
Base Score Calculation:
Final Score = Base Points ร Bonuses ร Penalties
Base Points = Puzzle difficulty (1-5) ร 100
Bonuses:
| Bonus | Multiplier | Condition |
|---|---|---|
| First Attempt | ร1.5 | Solve on first try |
| Speed Run | ร1.3 | Complete in <50% time limit |
| No Hints | ร1.2 | Solve without hints |
| Perfect Solution | ร1.5 | Optimal solution found |
| Streak | ร1.1 per win | Consecutive wins (max ร2.0) |
Penalties:
| Penalty | Multiplier | Condition |
|---|---|---|
| Hint Level 1 | ร0.9 | Used basic hint |
| Hint Level 2 | ร0.75 | Used specific hint |
| Hint Level 3 | ร0.5 | Used solution hint |
| Time Exceeded | ร0.8 | Over time limit |
- ๐ฅ Perfect Score: Solve puzzle with optimal solution
- ๐ Speed Run: Complete level in under 5 minutes
- ๐งฌ Master Breeder: Create agent with 0.95+ fitness
- ๐ค Coordinator: Successfully route 10,000 tasks
- ๐ Analyst: Export agent to production environment
Trained agents can be exported to:
# Export to pasture-ai
constraint-ranch export cattle-email-v1 --format=pasture-ai
# Export to constraint-flow (business)
constraint-ranch export duck-api-v2 --format=constraint-flow
# Export as breed.md (universal)
constraint-ranch export sheep-consensus-v1 --format=breedYour trained agents work in real systems.
// Game State
interface RanchState {
level: number;
agents: GameAgent[];
constraints: Constraint[];
score: ExactNumber; // Constraint Theory exact arithmetic
}
// Agent with exact positioning
interface GameAgent {
species: Species;
position: DodecetCoordinate; // Exact geometric position
traits: Map<Trait, ExactNumber>;
fitness: ExactNumber;
}
// Puzzle definition
interface ConstraintPuzzle {
type: 'spatial' | 'routing' | 'breeding' | 'coordination' | 'advanced';
constraints: Constraint[];
initialState: GameState;
goalState: Constraint[]; // Must all be satisfied
} โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Want to learn AI by playing? โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโผโโโโโ โโโโโโผโโโโโ โโโโโโผโโโโโ
โ GAMER โ โ TEACHER โ โ DEV โ
โโโโโโฌโโโโโ โโโโโโฌโโโโโ โโโโโโฌโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ โ Play โ โ โ Teach โ โ โ Export โ
โ & learn โ โ concepts โ โ agents โ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
Learning Outcomes:
- Understand constraint satisfaction through hands-on puzzles
- Learn exact arithmetic vs floating-point approximation
- Experience multi-agent coordination patterns
- Practice optimization and resource allocation
- Apply genetic algorithm concepts through breeding
Classroom Use:
- Works in any browser โ no installation needed
- Progressive difficulty for different skill levels
- Export agents for real-world applications
CS Concepts Taught:
| Concept | How It's Taught | Puzzle Type |
|---|---|---|
| Constraint Satisfaction | Position agents to satisfy multiple constraints | Spatial |
| Load Balancing | Distribute tasks without overloading agents | Routing |
| Genetic Algorithms | Breed agents with desired traits | Breeding |
| Distributed Consensus | Coordinate agents for group decisions | Coordination |
| System Design | Combine all concepts in complex scenarios | Advanced |
Research Foundations: This game is built on Constraint Theory, which enables:
- Exact arithmetic: No floating-point errors in calculations
- Deterministic solutions: Every puzzle has exactly one correct answer
- Snapping: Automatic alignment to valid positions
๐ Learn more: See constraint-theory-core for the mathematical foundations.
| Feature | Free | Premium |
|---|---|---|
| Agent Slots | 5 | Unlimited |
| Puzzle Levels | 1-10 | All levels |
| Night School | Manual | Auto-breed |
| Agent Export | 1/month | Unlimited |
| Custom Puzzles | โ | โ |
| Global Leaderboards | โ | โ |
No pay-to-win. Premium unlocks convenience, not advantages.
Constraint Ranch is part of the Constraint Theory ecosystem:
| Repo | What It Does | Key Features |
|---|---|---|
| constraint-theory-core | ๐ฆ Rust crate | ~100ns snap, SIMD batch, 82 tests |
| constraint-theory-python | ๐ Python bindings | NumPy integration, PyTorch compatible |
| constraint-theory-web | ๐ Interactive demos | 50 visualizations, zero setup |
| constraint-theory-research | ๐ Mathematical foundations | arXiv paper, proofs, open problems |
| constraint-ranch | ๐ฎ This repo | Puzzle games, agent breeding |
| constraint-flow | ๐ผ Business automation | Exact financial calculations, workflow orchestration |
| constraint-theory-agent | ๐ค Implementation agent | Code audit, refactoring, expert explanations |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CONSTRAINT ECOSYSTEM WORKFLOW โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ constraint- โ โ constraint- โ โ pasture-ai โ โ
โ โ theory-core โโโโโโถโ ranch โโโโโโถโ (production) โ โ
โ โ (Rust/WASM) โ โ (learn & train) โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ โ โ โ
โ โ โผ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ constraint- โโโโโโโโโโโโโโ โ
โ โ โ flow โ โ
โ โ โ (automation) โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Exact Arithmetic Foundation โ โ
โ โ โข No floating-point errors โ โ
โ โ โข Deterministic solutions โ โ
โ โ โข Cross-platform consistency โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Good First Issues ยท CONTRIBUTING.md
We welcome contributions:
- ๐ฎ New Puzzles - Design challenging constraint puzzles
- ๐ New Species - Add new agent types with unique abilities
- ๐จ Art & UI - Improve visual experience
- ๐ Translations - Make the ranch global
MIT โ see LICENSE.
Ready to run your ranch? Let's play! ๐ค