langton's army implementation with bevy + rust
Find a file
2025-06-02 14:06:10 +05:30
src init 2025-06-02 14:06:10 +05:30
.gitignore init 2025-06-02 13:36:49 +05:30
Cargo.lock init 2025-06-02 14:06:10 +05:30
Cargo.toml init 2025-06-02 14:06:10 +05:30
LICENSE init 2025-06-02 14:06:10 +05:30
README.md init 2025-06-02 13:36:49 +05:30

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

  1. At a white square, turn 90° clockwise, flip the color of the square, move forward one unit
  2. 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