This is the readme for my evolution simulator, The Life Engine.
FOR FEATURE REQUESTS, USE THE DISCUSSIONS TAB. FOR BUG REPORTS, USE THE ISSUES TAB. :)
# The Life Engine
[Play here!](https://thelifeengine.net/)
The life engine is a cellular automaton designed to simulate the long term processes of biological evolution. It allows organisms to eat, reproduce, mutate, and adapt.
Unlike genetic algorithms, the life engine does not manually select the most "fit" organism for some given task, but rather allows true natural selection to
run its course. Organisms that survive, successfully produce offspring, and out-compete their neighbors naturally propogate througout the environment.
This is the second version of the [original evolution simulator](https://github.com/MaxRobinsonTheGreat/EvolutionSimulator), which I started in high school.
# How to Run and Modify the Code
- [Install node and npm](https://nodejs.org/en/download/)
- Download or clone this repository
- Open a terminal or powershell comand prompt, go to the repository and run `npm install`
- Run `npm run build` (or `npm run build-watch` for a better developer experience)
- If you get a `Can't resolve jquery` error message run `npm install --save jquery`
- Open `dist/index.html` in your browser. The simulation should start running.
To load custom creations (found in `/dist/assets`), you must have a simple web server that serves all files in the dist directory. I do this with python:
- [Install python](https://www.python.org/downloads/)
- run `python -m http.server --directory dist` from the repository root
- Open `http://localhost:8000/` in your browser
### Npm build commands
- Production mode (minified): `npm run build`
- Watch mode (dev mode that auto-builds when you save a file): `npm run build-watch`
- Dev mode (better error messages): `npm run build-dev`
# How the Simulation Works
## The Environment
The environment is a simple grid system made up of cells, which at every tick have a certain type. The environment is populated by organisms, which are structures of multiple cells.
## Cells
A cell can be one of the following types.
### Independent Cells
Independent cells are not part of organisms.
- Empty - Dark blue, inert.
- Food - Grayish-blue, provides nourishment for organisms.
- Wall - Gray, blocks organisms movement and reproduction.
### Organism Cells
Organism Cells are only found in organisms, and cannot exist on their own in the grid.
- Mouth - Orange, eats food in directly adjacent cells.
- Producer - Green, randomly generates food in directly adjacent empty cells.
- Mover - Light blue, allows the organism to move and rotate randomly.
- Killer - Red, harms organisms in directly adjacent cells (besides itself).
- Armor - Purple, negates the effects of killer cells.
- Eye - Light purple with a slit, allows the organism to see and move intelligently. See further description below.
## Organisms
Organisms are structures of cells that eat food, reproduce, and die.
When an organism dies, every cell in the grid that was occupied by a cell in its body will be changed to food.
Their lifespan is calculated by multiplying the number of cells they have by the hyperparameter `Lifespan Multiplier`. They will survive for that many ticks unless killed by another organism.
When touched by a killer cell, an organism will take damage. Once it has taken as much damage as it has cells in its body, it will die. If the hyperparameter `One touch kill` is on, an organism will immediatly die when touched by a killer cell.
## Reproduction
Once an organism has eaten as much food as it has cells in its body, it will attempt to reproduce.
First, offspring is formed by cloning the current organism and possibly mutating it (see below).
The offspring birth location is then chosen a certain number of cells in a random direction (up, down, left, right). This number is calculated programmatically such that it is far enough away that it can't intersect with it's parent.
Additionally, a random value between 1 and 3 is added to the location to introduce a little variance.
Reproduction can fail if the offspring attempts to occupy non-empty cells, like other organisms and food. If reproduction fails, the food required to produce a child is wasted.
## Mutation
Offspring can mutate their anatomies in 3 different ways: change a cell, lose a cell, or add a cell. Changing a cell sets a random cell to a random type. Losing a cell removes a random cell. Note that this can result in organisms with "gaps" and cells disconnected from the rest of its body. I consider this a feature, not a bug.
To add a cell the organism first selects a cell it already has in its body, then grows a new cell with a random type in a location adjacent to the selected cell.
If an organism mutates, there is a 10% chance that mutation will alter the movement patterns of the organism (see below).
## Movement and Rotation
Organisms with mover cells (light blue) are permitted to move freely about the grid. Only a single mover cell is required and adding more doesn't do anything. By default, an organism selects a random direction and moves one cell per tick in that direction for a certain number of ticks. This number is called "Move range", and it can mutate over time.
Organims can also rotate around a central pivot cell. This cell can never be removed by mutation, though it can change type. Movers rotate randomly when they change direction, and their rotation is not necessarily the same as their movement direction, ie, they aren't always facing the direction they are moving. Offspring of all organisms (including static ones) rotate randomly during reproduction. This rotation can be toggled in the simulation controls.
## Eyes and Brains
Any organism can evolve eyes, but when an organism has both eyes and mover cells it is given a brain. The eye, unlike other cells, has a direction, which is denoted by the direction of the slit in the cell. It "looks" forward in this direction and "sees" the first non-empty cell within a certain range. It checks the type of the cell and informs the brain, which then decideds how to move. The brain can either ignore (keep moving in whatever direction), chase (move towards the observed cell), or retreat (move in the opposite direction of the observed cell). The brain maps different observed cell types to different actions. For instance, the brain will chase when it sees food and retreat when it sees a killer cell. These behaviors can mutate over time.
没有合适的资源?快使用搜索试试~ 我知道了~
生命引擎___下载.zip
共76个文件
js:44个
json:22个
md:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 153 浏览量
2023-04-16
19:44:16
上传
评论
收藏 1.48MB ZIP 举报
温馨提示
生命引擎___下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
生命引擎___下载.zip (76个子文件)
LifeEngine-master
Changelog.md 3KB
.github
ISSUE_TEMPLATE
feature_request.md 284B
bug_report.md 636B
webpack.config.js 313B
src
Hyperparameters.js 964B
Utils
Perlin.js 1KB
SerializeHelper.js 570B
Stats
StatsPanel.js 2KB
FossilRecord.js 5KB
Charts
CellsChart.js 2KB
MutationChart.js 789B
SpeciesChart.js 783B
PopulationChart.js 783B
ChartController.js 2KB
Species.js 1KB
Rendering
Renderer.js 3KB
ColorScheme.js 1KB
Organism
RandomOrganismGenerator.js 2KB
Organism.js 11KB
Directions.js 802B
Anatomy.js 4KB
Perception
Observation.js 198B
Brain.js 3KB
Cell
BodyCells
BodyCellFactory.js 1KB
ProducerCell.js 1KB
KillerCell.js 1016B
ArmorCell.js 252B
EyeCell.js 2KB
MouthCell.js 888B
BodyCell.js 2KB
MoverCell.js 294B
CellStates.js 2KB
GridCell.js 538B
Grid
GridMap.js 3KB
Neighbors.js 546B
Engine.js 3KB
WorldConfig.js 153B
Environments
WorldEnvironment.js 8KB
Environment.js 355B
OrganismEditor.js 4KB
index.js 2KB
Controllers
CanvasController.js 3KB
EnvironmentController.js 8KB
ControlModes.js 162B
ControlPanel.js 19KB
EditorController.js 8KB
LoadController.js 3KB
LICENSE 34KB
dist
assets
worlds
shrubland.json 6.14MB
compV2_fixed_labeled_fibofancy.json 3.26MB
_list.json 745B
computer_unprogrammed.json 4.74MB
scarcity.json 1.96MB
compV2_final_empty.json 3.1MB
world_HighDefSweepers_start.json 51KB
Life_Engine_of_Nurgle.json 1.69MB
colony.json 279KB
ephemeral.json 655KB
Trailblazer3.json 3.54MB
organisms
The_Anxious_Square.json 889B
RosaFinalis.json 996B
hunter.json 670B
flycatcher.json 6KB
_list.json 605B
Napoleon.json 1KB
purple_flower.json 1KB
HeartLocket.json 1KB
smallbushkiller.json 688B
img
title.png 560B
icon.png 207B
css
style.css 5KB
index.html 17KB
package.json 848B
package-lock.json 280KB
.gitignore 32B
README.md 6KB
共 76 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功