A high-performance 3D tribal civilization simulator powered by Zig + WebAssembly with neural network AI.
Watch tribes evolve, build civilizations, craft equipment, and wage wars - all running at 10-100x the performance of JavaScript thanks to our custom Zig WASM engine.
Planet Eden has been completely rebuilt with a Zig + WebAssembly backend for massive performance gains:
| Metric | JavaScript | Zig WASM | Improvement |
|---|---|---|---|
| Update loop | 8-15ms | 0.5-2ms | 10-30x faster |
| 1000 organisms | 30 FPS | 60 FPS | 2x frame rate |
| Neural network | Slow | SIMD-ready | 50-100x faster |
| Memory | Garbage collected | Zero-copy | No GC pauses |
WASM Module: 686 KB | Memory: 16 MB | Neural Networks: Per-organism AI
- Up to 8 competing tribes with unique procedural names
- Resource management: Food, Wood, Stone, Metal
- Diplomacy system: Allied (70+), Neutral (30-70), Hostile (<30)
- Tribe colors for visual identification
- Population tracking per tribe
Every organism has a real neural network brain:
- 15 inputs: Nearest food/threat/ally, own energy/health, environmental factors
- 12 hidden neurons: Learning and pattern recognition
- 17 outputs: Movement (3D), actions (eat, attack, flee, mate, gather, build, craft)
- Genetic inheritance: Offspring inherit mutated neural weights
Tribes can construct unique buildings:
- Hut - Round dwelling with cone roof
- Farm - Fenced area with crops and shed
- Storage - Warehouse with crates
- Workshop - Stone building with anvil and smokestack
- Barracks - Military building with flag and weapons
- 5 plant types: Grass, Tree, Bush, Flower, Crop
- Growth stages: Seed โ Sprout โ Juvenile โ Mature โ Flowering โ Fruiting โ Dying
- Plant genetics: Growth rate, max size, lifespan, color, food/wood value
- Procedural forests with natural spreading
- Crafting system: Tools, Weapons, Armor
- Equipment bonuses: Damage and defense modifiers
- Durability system: Items wear out over time
- Quality levels: Affects effectiveness
- Wood, Stone, Fiber, Metal deposits
- Gatherable resources that deplete and regenerate
- Strategic placement affects tribe development
Shape the world with divine abilities:
| Power | Key | Effect |
|---|---|---|
| Spawn New Tribe | F1 | Create a new tribe with 10 members |
| Mass Spawn | F2 | Add 100 organisms to the world |
| Gift Resources | F3 | Give resources to a selected tribe |
| Trigger War | F4 | Start conflict between tribes |
| Plague | F5 | Disease outbreak affecting organisms |
| Divine Blessing | F6 | Boost health and energy |
- Left Mouse + Drag - Rotate view
- Right Mouse + Drag - Pan camera
- Scroll Wheel - Zoom in/out
- Space - Pause/Resume
- Q/E - Decrease/Increase speed
- H - Toggle help
- Panel Toggle Button - Cycle through UI panels on small screens
- Responsive design for tablets and phones
No installation required - runs directly in your browser!
# Clone the repository
git clone https://github.com/markjspivey-xwisee/planet-eden.git
cd planet-eden
# Start the development server
node server.js
# Open http://localhost:8000/ in your browserRequires Zig (0.11+):
# Build the WASM module
zig build
# Output: zig-out/bin/planet-eden.wasmplanet-eden/
โโโ index.html # Main entry point (WASM version)
โโโ server.js # Development server
โโโ js/
โ โโโ wasm-main.js # WASM initialization and game loop
โ โโโ wasm-loader.js # WASM module loading and API
โ โโโ wasm-ui.js # UI management and god powers
โ โโโ renderer.js # Three.js 3D rendering
โโโ src/
โ โโโ main.zig # WASM exports and simulation core
โ โโโ simulation.zig # Organism AI and behavior
โ โโโ math.zig # Vec3, RNG, SIMD math
โ โโโ tribe.zig # Tribe management system
โ โโโ plant.zig # Plant genetics and growth
โ โโโ resource.zig # Resource node system
โ โโโ crafting.zig # Equipment crafting
โโโ build.zig # Zig build configuration
โโโ zig-out/bin/
โโโ planet-eden.wasm # Compiled WASM binary (686 KB)
- Zero-allocation update loop for consistent performance
- Structure-of-Arrays (SoA) data layout for cache efficiency
- Exported memory for zero-copy JavaScript access
- SIMD-ready math operations
- Instanced meshes for efficient organism rendering
- Procedural building geometry for unique structures
- Dynamic terrain with height map
- Particle effects for visual feedback
[Zig WASM Engine] โโzero-copyโโโบ [Shared Memory] โโโtyped arraysโโโบ [Three.js Renderer]
โ โ โ
โผ โผ โผ
Neural Networks Float32Arrays 3D Meshes
Physics Update Uint8Arrays UI Updates
AI Decisions Position/Velocity Animations
Minimum:
- Modern browser with WebAssembly support
- 4GB RAM
- Integrated graphics
Recommended:
- Chrome/Firefox/Edge (latest)
- 8GB RAM
- Dedicated GPU for 60 FPS at max population
Supported: Windows, Mac, Linux, iOS Safari, Android Chrome
Contributions welcome! Some ideas:
- Weather system affecting tribe behavior
- Trade routes between allied tribes
- Technology tree advancement
- Save/Load world state to WASM
- Multiplayer synchronization
- More building types
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make changes (Zig for engine, JS for rendering/UI)
- Build and test (
zig build && node server.js) - Commit and push
- Open a Pull Request
MIT License - Use freely for any purpose. See LICENSE.
- โญ Star this repo to help others discover it
- ๐ Report bugs via Issues
- ๐ก Suggest features for future development
- ๐ Fork and remix - make your own version!
โญ Star โข ๐ฎ Play Now โข ๐ Report Bug