langton's army implementation with bevy + rust
- Rust 100%
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
Langton's Ant Simulation
A Bevy-based implementation of Langton's Ant cellular automaton with a clean, modular architecture.
Project Structure
src/
├── main.rs # Application entry point and configuration
├── components.rs # ECS components (Ant, Direction, GridCell, AntSprite)
├── constants.rs # Configuration constants and colors
├── grid.rs # Grid state management and logic
└── systems.rs # Bevy systems for setup and updates
Features
- Modular Design: Clean separation of concerns across multiple modules
- Configurable: Easy to modify grid size, colors, and simulation speed
- Efficient: Uses HashMap for sparse grid representation
- Real-time Visualization: Smooth animation with Bevy's ECS architecture
How to Run
cargo run
Langton's Ant Rules
- At a white square, turn 90° clockwise, flip the color of the square, move forward one unit
- At a black square, turn 90° counter-clockwise, flip the color of the square, move forward one unit
Configuration
Modify src/constants.rs to adjust:
- Grid size
- Cell size
- Simulation speed
- Colors
Architecture Benefits
- Maintainability: Each module has a single responsibility
- Testability: Components and logic are easily unit testable
- Extensibility: Easy to add new features like multiple ants or different rules
- Readability: Clear separation makes the code easier to understand