Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SHOW THE MATLAB CODE FOR THE FOLLOWING: In this assignment you will be using Matlab to create a virtual environment, virtual animals, then using the

SHOW THE MATLAB CODE FOR THE FOLLOWING:
In this assignment you will be using Matlab to create a virtual environment, virtual animals, then using the principles of natural selection to evolve a population. You will make simple animals represented as particles that are capable of using energy to forage for food. Here are the parameters:
Environment:
Make a bounding box that is 2000 x 2000 units. Within this environment, create 50 food particles that are randomly dispersed throughout.
Code Example:
boxsize =[20002000];
foodno =50
food =[rand(foodno,1)* boxsize(1) rand(foodno,1)* boxsize(2)];
Animals:
Each animal is represented as a particle with two traits the first is speed and the second is sense. The animal also has energy and a location. During a given day cycle the animal uses energy to forage for food by doing a random walk (with caveats explained below). If it runs into the bounding box (or moves across it), just set its location to the edge of the bounding box for that step.
Define your animals in an array with the following variables (explained below).
animal =[xlocation ylocation foodcount energy speed sense];
Part 1
Initial Simulation No Evolution There is no variation in the population... all animals start with same parameters (could also do this with variation but no heredity)
Start with somewhere between 10 and 20 animals. Each day, the animals start randomly located along the borders of the environment. Then they go about foraging for food by taking random steps. Each can take a max of 2000 steps per day if it has enough energy. Once an animal runs out of energy it must stop for the day.
If the animal comes within 10 units of a piece of food, it can move at its normal speed toward that piece of food (using that amount of energy) and eat it (provided another animal doesnt get there first) that piece of food is then removed from the environment for the day. If it overshoots the food, it also eats it.
If an animal eats one piece of food it lives on to the next day, if it eats 0 pieces of food, it dies and is removed from the environment (delete from array). If it eats two or more pieces of food it replicates (only one offspring regardless of food).
A day in this scenario represents a generation. Run the simulation for 200 generations (make a loop) and do this 10 times (each time is an independent simulation).
Plots:
Make plots of the birth rate and death rate as a function of day cycles (should have 10 curves).
Make a plot of the population growth (or decline) as a function of generation (should have 10 curves).
Make an animation of your simulation of the animals moving around eating food. (open ended)
Once you are done with this part. Feel free to play around with both the environment and the animals to see if you can create different population behaviors. Feel free to introduce some variation into the traits of the starting population but these cannot be passed to the offspring (e.g. when an animal has offspring it gets a new random set of traits)
Be prepared to demonstrate your simulation and discuss its behavior. (open ended)
Initial Conditions:
Starting energy each day (note to keep it simple, this is not tied to food): 1600000
speed =50;
sense =10;
Here is some code to show you how to move the animal on step and expend energy:
xmove =(rand(1)* speed - rand(1)*speed);
ymove =(rand(1)* speed - rand(1)*speed);
animal =[animal(1)+ xmove animal(2)+ ymove];
energy = energy - norm([xmove ymove])^2- sense; %both sense and speed have energetic costs
Part 2
Part two will use the framework you developed in part 1 but now you will introduce random heritable variation in the traits. For a given simulation, allow your population to have random variation in the speed and sense traits of +/-50%. That means each animal will have a different speed and ability to detect food. At the end of each day, surviving animals pass their speed and sense traits on to their offspring (vary these by +/-5%).
Before starting the simulation, make predictions on which way your species will evolve, if at all.
Plot each animal as a particle on an animated 2D plot with speed on the x-axis and sense on the y-axis.
Finally play around with the environment (size, amount of food), number of initial population of animals, variation in each trait or introduce a third trait (be creative).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions