A procedurally generated ant farm simulation game built with Bevy and Rust. Watch as worker ants dig and explore through a dynamically generated terrain, creating tunnels and expanding their colony.
- Procedurally generated terrain with different layers (Surface, Dirt, Stone, Deep, Bedrock)
- Terrain features including caves, water pockets, resource veins, and tunnels
- Ant colony simulation with worker ants that dig and explore
- Camera controls for exploring the world
- Chunk-based terrain loading system
- WebAssembly support for playing in the browser
- Physics simulation using Bevy Rapier2D
- Pathfinding system for ant navigation
- Dynamic terrain modification
- Central colony cavity with surrounding tunnels
- Hot reloading for WASM development
- Tile-based world with 8x8 pixel tiles
- Multiple tile types (Dirt, Air) with different properties
- Dynamic terrain modification through digging
- Central cavity generation for colony starting point
- Efficient tile storage and retrieval system
- Worker ants with autonomous digging behavior
- State-based ant AI (Searching, Moving, Digging)
- Pathfinding system for efficient navigation
- Configurable ant parameters:
- Maximum colony distance: 500 units
- Worker work radius: 400 units
- Dig chance: 80%
- Branch chance: 5%
- Search radius: 100 units
- Ant speed: 100 units/second
- Central colony hub
- Worker ant spawning and management
- Resource gathering and distribution
- Colony expansion through tunnel networks
- Rust and Cargo (latest stable version)
- wasm-pack (for WebAssembly builds)
- Python 3 (for local development server)
- Python packages (install with
pip install -r requirements.txt)
The project uses a Makefile for building and running. Here are the available commands:
# Show help
make help
# Build for WebAssembly
make wasm
# Build for native platform
make native
# Build for both WASM and native
make all
# Run the native build
make run
# Serve the WASM build locally
make serve
# Serve with auto-rebuild on file changes
make watch
# Check if WASM build is valid
make check
# Test the WASM build with a simple server
make test
# Clean build artifacts (except Bevy dependencies)
make clean-
Install Python dependencies:
pip install -r requirements.txt
-
Start the development server with hot reloading:
make watch
-
The browser will automatically open to http://localhost:8000
- Any changes to Rust source files will trigger automatic rebuild
- The page will automatically reload when the build is complete
- Press Ctrl+C to stop the server
- WASD: Move camera
- Space: Spawn new worker ants
- Mouse Click: Command ants to move to a location
src/: Source codelib.rs: Library entry point and plugin setupmain.rs: Binary entry pointant/: Ant-related codemod.rs: Main module file with plugin setupcomponents.rs: Ant-related components and constantssystems.rs: Systems for ant movement and interactionbehaviors.rs: Core ant behavior logicapp.rs: Application setup for both WASM and native buildspathfinding.rs: Pathfinding implementation for ant navigation
colony.rs: Colony management and simulationterrain/: Terrain generation and managementmod.rs: Terrain system implementation
public/: Web deployment filesindex.html: Main HTML file for WASM deploymentpkg/: WASM build output
assets/: Game assets and resourceswatch.py: Development server with hot reloadingserve.py: Basic development serverrequirements.txt: Python dependencies
- The project uses optimized build settings for better performance
- Debug builds include some optimization for faster development
- Release builds use full optimization with LTO enabled
- Bevy dependencies are preserved during cleaning to avoid long rebuilds
- Physics simulation is configured for top-down 2D movement with no gravity
- Tile system uses a custom hash implementation for efficient storage
- Ant pathfinding system supports dynamic obstacle avoidance
- Hot reloading is available for WASM development with
make watch
This project is licensed under the MIT License - see the LICENSE file for details.