Bitvolve is a Python-based simulation that models evolution using "bits" (small creatures represented as squares) in a 2D environment via the Turtle graphics library. Bits have genetic "features" (e.g., movement, repetition, conditional logic, following, or killing others) encoded as strings. They evolve over "days" based on user-defined survival criteria (regions on the screen where bits must end up to survive). Surviving bits reproduce with mutations, and the simulation tracks gene prevalence over time, concluding with a graphical summary.
The simulation incorporates randomness, user input for customization, and optional developer modes for tweaking behaviors like murder, mutations, or performance.
- Interactive Setup: Define survival regions (using lines like
Y=MX+Cor X/Y thresholds), bit size, population size, mutation rates, reproduction chances, and more. - Evolution Mechanics: Bits move based on their genes. At the end of each "day," bits outside survival regions die. Survivors mutate and reproduce.
- Genes/Features: 11 traits:
a: Move forwardb: Diagonal (Y=X)c: Diagonal (Y=-X)d: Repeat embedded features N timese: Null (do nothing)f: Kill closest bit within rangeg: Follow closest bith: If position meets condition, run embedded featuresi: Move rightj: Move leftk: Move backward
- Developer Mode: Options to disable murder, restrict genes, use cycle-based days, beep on kills, etc.
- Visualization: Real-time Turtle graphics show bit movement. Ends with a line graph of gene abundance (or mean per bit) over days.
- Audio Feedback: Uses
winsoundfor beeps during events (Windows-only; simulation runs without audio on other OS). - Respawn: If all bits die, they can respawn from the last generation (optional).
- Python 3.x (tested with Python 3.12+, but should work on 3.6+).
- Standard libraries:
random,time,turtle. - Windows-specific:
winsoundfor audio (beeps are skipped on other OS). - No external packages required.
Note: Maximize the Turtle window when prompted for optimal visualization. Screen dimensions are ~1400x700 pixels.
- Save the script as
bits_evolution.py. - Run it in a Python environment:
python bits_evolution.py
- Ensure your terminal supports input prompts.
- On non-Windows systems, comment out
winsoundlines if errors occur.
- Run the script.
- Follow console prompts to configure:
- Number of survival criteria (0–12 regions).
- For each criterion: Choose
Y=MX+Cor X/Y thresholds. Preview shaded survival regions. - Bit size (1–5; affects max population and speed).
- Initial bit count (up to ~1000/size²).
- Max features per bit.
- Day length (seconds or cycles in developer mode).
- Mutation rate (1 in N chance).
- Reproduction rate for 2 children (1 in N; optional).
- Murder success rate (1 in N).
- Random starting bits/positions (Y/N).
- Random positions at end of day (Y/N).
- Gene weights (customize rarity or equal).
- Respawn on extinction (Y/N).
- Developer mode (optional tweaks).
- A countdown starts, then the simulation runs in the Turtle window.
- Bits move, interact (follow/kill), and die if out-of-bounds or murdered.
- Top HUD shows Day, Cycle, and Bit count.
- When all bits die (or the window is closed), check the console for final bit compositions.
- A graph displays gene abundance (or mean per bit) over days.
- Click to exit the graph.
Controls:
- Close the Turtle window to end the simulation early.
- No real-time interaction; all setup is via console prompts.
Enter Y when prompted for developer mode. Options (multiple allowed):
- Disable murder.
- Delete murder genes until a specific day.
- Ban specific genes from occurring.
- Use cycles instead of seconds for day length.
- Murder only affects bits with murder genes.
- Overload: Max bits (~2000/size²).
- Beep on murders.
- Trace bit paths (draw lines).
- Console: Logs bit deaths, errors, and final compositions.
- Graph: Multi-line plot of gene counts (or means) over days. Black line for bit population.
- Mean Mode: Abundance divided by bit count for per-bit averages.
- Windows-only audio (
winsound); port to cross-platform if needed (e.g.,playsound). - No save/load; runs fresh each time.
- Slowdowns with high bit counts/large sizes due to Turtle graphics.
- Basic error handling; invalid inputs may crash—follow prompts carefully.
- Graph scales dynamically but may overlap labels on extreme values.
- Tested on Windows; Turtle behavior may vary on macOS/Linux.
This is an educational project. Feel free to fork and improve (e.g., add cross-platform audio, optimize rendering, or add more genes). Pull requests are welcome!
MIT License - Free to use/modify with attribution.
Created on September 12, 2025. If issues arise, check the console for tracebacks. Enjoy evolving your bits! 🐢