I am trying to replicate the simulation model presented in the following youtube video using python: https://www.youtube.com/watch?v=0ZGbIKd0XrM&vl=en
The thoughts and ideas presented in that video are not my own and all credit should go to the owner of that channel / video / content. I am using the thoughts and ideas in that video educationally - as a prompt to improve my skills in python.
This is an offshoot of a school assignment here.
This repository packages the simulation specific code into a package that can be used on its own, or plugged into another GUI / API.
pip install --upgrade git+https://github.com/christian-million/NS-MODEL.git
from ns_model import Model
# Runs with default parameters if no arguments passed
test_model = Model()
# Runs Model
test_model.run()
# Prints a population summary
print(test_model.pop_sum)
Improvements that need to be made:
-
Do not remove dead agents during a
for
loop -
Restructure so that all moves are evaluated first, then executed simultaneously
-
Look for opportunities to reduce run time / improve efficiency
-
N_AGENTS
: The initial population size of the model -
N_FOOD
: The amount of food available on each newday
-
N_DAYS
: How manydays
the model will run -
DAILY_STEPS
: How manysteps
are available in eachday
-
PREDATOR_RATIO
: The percent difference insize
betweenAgents
that dictates who is prey / predator. (e.g.,Agent
A is 20% larger thanAgent
B.Agent
A is a predator toAgent
B) -
FOOD_SIZE
: How big is the food. This impacts an Agents ability tosense
the food. -
FOOD_VALUE
: How nutritious is the food. -
EAT_DIST
: How close anAgent
has to be in order to eat the food / otherAgent
. -
HEIGHT
: The Y value of the environment grid -
WIDTH
: The X value of the environment grid -
HEADING_MOD
: Whenwandering
how many degrees (+-) can anAgents
heading
change -
STEP_BUFFER
: How many steps Agents will allow themselves to begin heading home. If it will take X steps to get home, the agent will start heading home at X + STEP_BUFFER steps remaining.
-
MUTATION_RATE
: How likely is a mutation during reproduction -
REPRODUCTION_MOD
: What percentage of energy (relative to it's own) must a Agent eat in order to reproduce. -
SPEED
: Speed of initial cohort of Agents (Distance traveled in 1 step) -
SIZE
: Size of initial cohort of Agents (Radius of body) -
SENSE
: Sense of initial cohort of Agents (Radius of detection) -
SPEED_MOD
: What percentage can speed increase/decrease on mutation -
SIZE_MOD
: What percentage can size increase/decrease on mutation -
SENSE_MOD
: What percentage can sense increase/decrease on mutation -
SPEED_ALLOW
: Allow speed mutations? -
SIZE_ALLOW
: Allow size mutations? -
SENSE_ALLOW
: Allow sense mutations?