Answered step by step
Verified Expert Solution
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 x units. Within this environment, create food particles that are randomly dispersed throughout.
Code Example:
boxsize ;
foodno
food randfoodno boxsize randfoodno boxsize;
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
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 and 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 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 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 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 generations make a loop and do this 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 curves
Make a plot of the population growth or decline as a function of generation should have 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 eg 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:
speed ;
sense ;
Here is some code to show you how to move the animal on step and expend energy:
xmove rand speed randspeed;
ymove rand speed randspeed;
animal animal xmove animal ymove;
energy energy normxmove ymove sense; both sense and speed have energetic costs
Part
Part two will use the framework you developed in part 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 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
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 D plot with speed on the xaxis and sense on the yaxis.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started