Skip to content

hasan-mustafaa/Bitvolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Bitvolve

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.

Features

  • Interactive Setup: Define survival regions (using lines like Y=MX+C or 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 forward
    • b: Diagonal (Y=X)
    • c: Diagonal (Y=-X)
    • d: Repeat embedded features N times
    • e: Null (do nothing)
    • f: Kill closest bit within range
    • g: Follow closest bit
    • h: If position meets condition, run embedded features
    • i: Move right
    • j: Move left
    • k: 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 winsound for 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).

Requirements

  • Python 3.x (tested with Python 3.12+, but should work on 3.6+).
  • Standard libraries: random, time, turtle.
  • Windows-specific: winsound for 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.

Installation

  1. Save the script as bits_evolution.py.
  2. Run it in a Python environment:
    python bits_evolution.py
    • Ensure your terminal supports input prompts.
    • On non-Windows systems, comment out winsound lines if errors occur.

Usage

  1. Run the script.
  2. Follow console prompts to configure:
    • Number of survival criteria (0–12 regions).
    • For each criterion: Choose Y=MX+C or 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).
  3. 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.
  4. When all bits die (or the window is closed), check the console for final bit compositions.
  5. A graph displays gene abundance (or mean per bit) over days.
  6. 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.

Developer Mode

Enter Y when prompted for developer mode. Options (multiple allowed):

  1. Disable murder.
  2. Delete murder genes until a specific day.
  3. Ban specific genes from occurring.
  4. Use cycles instead of seconds for day length.
  5. Murder only affects bits with murder genes.
  6. Overload: Max bits (~2000/size²).
  7. Beep on murders.
  8. Trace bit paths (draw lines).

Output

  • 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.

Limitations/Known Issues

  • 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.

Contributing

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!

License

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! 🐢

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages