Skip to content

Ptchwir3/Aetharia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โš” AETHARIA โš”

An open-source, distributed metaverse you can run with a single command.

Aetharia is a multiplayer 2D world with procedural terrain, server-side physics, AI agents that build autonomously, and an architecture designed to scale across Kubernetes clusters โ€” from Raspberry Pis to cloud servers.

Inspired by Ready Player One's OASIS. Built for hackers, tinkerers, and dreamers.

Status License Docker


๐ŸŽฎ What You Get

  • Procedural terrain โ€” Terraria-style world generated from a seed (same seed = same world everywhere)
  • Server-side gravity โ€” Physics run on the server, so all clients (humans and AI) play by the same rules
  • Multiplayer โ€” See other players in real time with custom names and colors
  • AI agents โ€” Three autonomous NPCs (Claude, Atlas, Forge) explore and build structures while you play
  • Real-time world modification โ€” AI agents place blocks and everyone sees the changes instantly
  • Zone architecture โ€” World is divided into zones, ready for horizontal scaling across cluster nodes
  • Profile picker โ€” Choose your name and color on connect
  • Chat system โ€” Zone-scoped chat (press T to talk)

๐Ÿš€ Quick Start (Docker Compose)

git clone https://github.com/Ptchwri3/Aetharia.git
cd Aetharia
docker compose up --build

Open your browser to:

http://localhost:3500

That's it. You're in.

Multiple players? Open more browser tabs, or connect from other devices on your network:

http://<YOUR_IP>:3500/?server=<YOUR_IP>:8080

To stop:

docker compose down

To rebuild after code changes:

docker compose up --build

๐Ÿ— Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     WebSocket      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Browser    โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚     Backend (port 8080)      โ”‚
โ”‚   (Phaser)   โ”‚                    โ”‚                              โ”‚
โ”‚  port 3500   โ”‚                    โ”‚  โ€ข WebSocket game server     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                    โ”‚  โ€ข Server-side gravity       โ”‚
                                   โ”‚  โ€ข Zone management           โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     WebSocket      โ”‚  โ€ข Procedural terrain gen    โ”‚
โ”‚  AI Agents   โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚  โ€ข World state persistence   โ”‚
โ”‚  (Node.js)   โ”‚                    โ”‚  โ€ข Anti-cheat validation     โ”‚
โ”‚  Claude      โ”‚                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚  Atlas       โ”‚
โ”‚  Forge       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Services

Service Port Description
backend 8080 WebSocket game server โ€” handles all game logic, physics, terrain, chat
frontend 3500 Phaser 3 browser client โ€” renders world, handles input
agents โ€” AI agents that connect as players, explore, and build structures

๐Ÿ“ Repository Structure

Aetharia/
โ”œโ”€โ”€ Backend/
โ”‚   โ””โ”€โ”€ Src/
โ”‚       โ”œโ”€โ”€ main.js              # Server entry โ€” connections, physics loop, broadcasting
โ”‚       โ”œโ”€โ”€ Handlers/
โ”‚       โ”‚   โ””โ”€โ”€ handleMessage.js # Message routing โ€” move, chat, blocks, profiles
โ”‚       โ”œโ”€โ”€ Player/
โ”‚       โ”‚   โ””โ”€โ”€ player.js        # Player factory with physics state
โ”‚       โ”œโ”€โ”€ World/
โ”‚       โ”‚   โ”œโ”€โ”€ terrainGen.js    # Seeded procedural terrain generation
โ”‚       โ”‚   โ”œโ”€โ”€ zoneManager.js   # Zone assignment and player tracking
โ”‚       โ”‚   โ””โ”€โ”€ worldState.js    # Block modification persistence
โ”‚       โ””โ”€โ”€ Utils/
โ”‚           โ”œโ”€โ”€ constants.js     # Path resolver for shared constants
โ”‚           โ””โ”€โ”€ logger.js        # Leveled logging
โ”‚
โ”œโ”€โ”€ Frontend/
โ”‚   โ””โ”€โ”€ Public/
โ”‚       โ”œโ”€โ”€ index.html           # Game page with loading screen
โ”‚       โ””โ”€โ”€ Src/
โ”‚           โ””โ”€โ”€ main.js          # Phaser client โ€” rendering, input, networking
โ”‚
โ”œโ”€โ”€ AI_Agents/
โ”‚   โ”œโ”€โ”€ index.js                 # Agent spawner โ€” connects 3 AI players
โ”‚   โ”œโ”€โ”€ Decision_Engine/
โ”‚   โ”‚   โ””โ”€โ”€ index.js             # Physics-aware building decisions
โ”‚   โ””โ”€โ”€ Memory_Core/
โ”‚       โ””โ”€โ”€ index.js             # World knowledge storage
โ”‚
โ”œโ”€โ”€ Shared/
โ”‚   โ””โ”€โ”€ Utils/
โ”‚       โ””โ”€โ”€ constants.js         # Shared config (tiles, zones, physics, messages)
โ”‚
โ”œโ”€โ”€ Helm/                        # Kubernetes Helm chart (ready for cluster deploy)
โ”œโ”€โ”€ K8S/                         # Raw Kubernetes manifests
โ”œโ”€โ”€ docker-compose.yml           # One-command full stack deployment
โ””โ”€โ”€ .dockerignore

๐ŸŽฎ Controls

Key Action
A / โ† Move left
D / โ†’ Move right
W / โ†‘ / Space Jump
T Open chat
Enter Send chat message
Escape Close chat

๐Ÿค– AI Agents

Three AI agents connect automatically and inhabit the world:

Agent Personality Behavior
Claude Architect Plans and builds watchtowers, shelters
Atlas Explorer Traverses the world, requests new chunks
Forge Builder Constructs structures more frequently

Agents are physics-aware โ€” they build on solid ground, verify flat areas before construction, and their blocks must have structural support. They walk along the terrain surface just like human players.

Future: These agents are designed to be upgraded with LLM intelligence (local models via Rookery or cloud APIs) for genuine reasoning, conversation, and creative building.


โš™๏ธ Configuration

Environment Variables (Backend)

Variable Default Description
PORT 8080 WebSocket server port
AETHARIA_WORLD_SEED 12345 World generation seed (same seed = same world)
AETHARIA_HEARTBEAT 30000 Heartbeat interval (ms)
AETHARIA_DEBUG false Enable debug logging

Environment Variables (Agents)

Variable Default Description
BACKEND_URL ws://localhost:8080 Backend WebSocket URL
AGENT_TICK_RATE 500 Decision loop interval (ms)

๐Ÿ›  Local Development (No Docker)

Backend

cd Backend
npm install
npm start
# Server running on ws://localhost:8080

Frontend

cd Frontend
npm install
npx serve Public -l 3500
# Open http://localhost:3500/?server=localhost:8080

AI Agents

cd AI_Agents
npm install
BACKEND_URL=ws://localhost:8080 npm start

โ˜ธ๏ธ Kubernetes Deployment (Helm)

Aetharia ships with a Helm chart for cluster deployment. The zone architecture maps naturally to Kubernetes pods โ€” each zone can run on a separate node.

# Build and push images
docker build -t youruser/aetharia-backend:latest -f Backend/Dockerfile .
docker build -t youruser/aetharia-frontend:latest -f Frontend/Dockerfile .
docker build -t youruser/aetharia-agents:latest -f AI_Agents/Dockerfile .

docker push youruser/aetharia-backend:latest
docker push youruser/aetharia-frontend:latest
docker push youruser/aetharia-agents:latest

# Update Helm/values.yaml with your image repository

# Deploy
helm upgrade --install aetharia ./Helm \
  --namespace aetharia \
  --create-namespace

# Verify
kubectl get pods -n aetharia
kubectl get svc -n aetharia

๐Ÿ—บ Roadmap

  • Procedural terrain generation (seeded, deterministic)
  • Multiplayer WebSocket server with zone management
  • Server-side gravity and collision physics
  • AI agents that explore and build
  • Player profiles (name + color picker)
  • Real-time world modification (block place/remove)
  • Chat system (zone-scoped)
  • Docker Compose deployment
  • LLM-powered AI agents (via Rookery distributed inference)
  • Player block placement (click to build/mine)
  • Sprite tilesets (replace colored rectangles with pixel art)
  • Helm deployment across multi-node K8s cluster
  • Day/night cycle
  • Inventory system
  • VR/3D client (Unity/Unreal)

๐Ÿงฑ Technical Details

Terrain Generation

  • Seeded PRNG (mulberry32) ensures deterministic generation
  • Chunk-based: 32ร—32 tiles per chunk, generated on demand
  • Terraria-style layers: air โ†’ grass โ†’ dirt โ†’ stone
  • Surface noise with multiple octaves for natural hills
  • Trees, caves, water, sand beaches

Server-Side Physics

  • 20 tick/sec physics loop applies gravity to all connected entities
  • Collision detection against world tiles (solid vs air/water)
  • Jump velocity, max fall speed, head bonk on ceilings
  • Unstick logic prevents players from getting trapped in terrain
  • Authoritative position โ€” server corrects client positions

Zone System

  • World divided into 5 zones (central, north, south, east, west)
  • Players assigned to zones based on tile position
  • Zone-scoped broadcasting (players only receive updates from their zone)
  • Designed for horizontal scaling: each zone โ†’ separate pod/node

World State

  • Modifications stored as overrides on procedural terrain
  • Base terrain is never mutated โ€” generated fresh from seed
  • Block changes persist in memory (future: Redis/disk)
  • All clients receive real-time block update broadcasts

๐Ÿ‘ค Maintainer

Josh "Ptchwir3" Nelson Builder of decentralized systems, autonomous drones, and experimental metaverse architectures.


๐Ÿ“„ License

MIT โ€” do whatever you want with it.

Releases

No releases published

Packages

 
 
 

Contributors

Languages