Skip to content

markjspivey-xwisee/planet-eden

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

77 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ Planet Eden - WASM Tribal Civilization Simulator

Live Demo License: MIT GitHub stars

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.


๐Ÿš€ WASM-Powered Performance

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


โœจ Key Features

๐Ÿ›๏ธ Tribal Civilization System

  • 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

๐Ÿง  Neural Network AI (15โ†’12โ†’17)

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

๐Ÿ—๏ธ Building System

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

๐ŸŒฑ Advanced Plant System

  • 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

โš”๏ธ Combat & Equipment

  • Crafting system: Tools, Weapons, Armor
  • Equipment bonuses: Damage and defense modifiers
  • Durability system: Items wear out over time
  • Quality levels: Affects effectiveness

๐ŸŒ Resource Nodes

  • Wood, Stone, Fiber, Metal deposits
  • Gatherable resources that deplete and regenerate
  • Strategic placement affects tribe development

๐ŸŽฎ God Powers

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

๐ŸŽฏ Controls

Camera

  • Left Mouse + Drag - Rotate view
  • Right Mouse + Drag - Pan camera
  • Scroll Wheel - Zoom in/out

Simulation

  • Space - Pause/Resume
  • Q/E - Decrease/Increase speed
  • H - Toggle help

Mobile

  • Panel Toggle Button - Cycle through UI panels on small screens
  • Responsive design for tablets and phones

๐Ÿš€ Quick Start

Play Online (Instant)

๐Ÿ‘‰ Click here to play now!

No installation required - runs directly in your browser!

Run Locally

# 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 browser

Build WASM from Source (Optional)

Requires Zig (0.11+):

# Build the WASM module
zig build

# Output: zig-out/bin/planet-eden.wasm

๐Ÿ“ Project Structure

planet-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)

๐Ÿ› ๏ธ Technical Architecture

Zig WASM Engine

  • 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

Three.js Renderer

  • Instanced meshes for efficient organism rendering
  • Procedural building geometry for unique structures
  • Dynamic terrain with height map
  • Particle effects for visual feedback

Data Flow

[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

๐Ÿ“Š System Requirements

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


๐Ÿค Contributing

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

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make changes (Zig for engine, JS for rendering/UI)
  4. Build and test (zig build && node server.js)
  5. Commit and push
  6. Open a Pull Request

๐Ÿ“œ License

MIT License - Use freely for any purpose. See LICENSE.


๐ŸŒŸ Show Your Support

  • โญ Star this repo to help others discover it
  • ๐Ÿ› Report bugs via Issues
  • ๐Ÿ’ก Suggest features for future development
  • ๐Ÿ”€ Fork and remix - make your own version!

Made with Zig, Three.js, and Claude AI

โญ Star โ€ข ๐ŸŽฎ Play Now โ€ข ๐Ÿ› Report Bug

Releases

No releases published

Packages

 
 
 

Contributors