No description
  • JavaScript 80.9%
  • HTML 13.6%
  • CSS 5.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2023-06-14 16:50:54 -05:00
css Move and fix the GitHub banner 2023-06-14 16:49:45 -05:00
js Color swatches instead of text colors (#28) 2017-02-09 08:44:05 -05:00
index.html Move and fix the GitHub banner 2023-06-14 16:49:45 -05:00
LICENSE Prettier formatted LICENSE 2016-02-18 17:31:20 -05:00
README.md Small phrasing fix for the README 2023-06-14 16:50:54 -05:00
test.html Size does not affect color 2015-11-17 11:52:40 -05:00

Darwin's Game of Evolution

Check out a live running version on my website.

Running

  • Simply open index.html in your browser.

Controls

There aren't a lot of "controls," per se, but there are a few interactive features.

  • Click to enable the "inspect" element. It will jump to your mouse and show you the DNA of the creature that you are currently hovering over. When you move your mouse, the "inspect" element will follow.
  • Click "Reset" to reset the game to it's beginning state.

Rules

Individuals

  • Individuals reproduce asexually.
  • When reproducing, the offspring can appear on any of the four spaces around the parent, top, right, bottom, or left.
  • Offspring have a copy of their parent's DNA, with a %1 chance of a random mutation.
  • Individuals who do not eat after 25 turns (2.5 seconds) die of starvation.
  • Individuals have a maximum lifespan (10 seconds).
  • Individuals can eat any other individuals, in accordance with their DNA.
  • Individuals have a size (0 - 5, inclusive). Individuals can only eat other individuals that are smaller than them.
    • TODO: Hitpoints?

Game

  • The game will end only by one of the following:
    • All individuals are dead
    • The "Reset" button is pressed
  • The game starts with 5000 individuals

Development

The game code is in four files:

  • js/game.js
  • js/creature.js
  • js/dna.js
  • js/inspect.js

There is also js/canvas_adapter.js, but it should not need to be modified other than for performance reasons.

game.js

  • Should contain all non-creature game logic
  • Creates the board
  • Creates individuals and places them on the board
  • Redraws the game
  • Restarts the game when it is "over", as defined above

creature.js

  • All creature behavior
  • Creature configuration (lifespan, starvation)

dna.js

  • Handles creation of DNA
  • Handles copying of DNA

inspect.js

  • Handles the mouse-over action of showing the creature's DNA

LICENSE

This is MIT Licensed. You can find the whole license in the LICENSE file.