Simulate a living system of predators-preys

Assignment Help Simulation in MATLAB
Reference no: EM133284213

Engineering Analysis and Numerical Methods

Introduction

The main goal of this assignment is to simulate a living system of predators-preys and its evolution according to a simplified set of rules of death and survival. The living system is represented by the following elements:

• A square grid of cells (represented in a MATLAB environment as a 2D array).

• A representations in each square for the prey, predator, and bare ground (represented in a MATLAB environment with a numerical encoding).

• A set of rules that each square will obey designed to imitate the behaviour of the prey, predator, or bare ground (represented in a MATLAB environment with a set of conditional statements).

Problem description

The living system is represented as a 2D array of any size, predators, prey and bare ground have the following encoding
• Predator → 2
• Prey → 1
• Bare Ground → 0

This is for example a 6x6 living system with 8 preys and 2 predators

2 0 0 1 0 0
0 1 1 0 0 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 2 1 0 0
0 0 1 1 0 0

Each cell has 8 surrounding cells. For example the surrounding cells of the cell at position (2,2), that represents a prey, are the one highlighted in bold

2 0 0 1 0 0
0 1 1 0 0 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 2 1 0 0
0 0 1 1 0 0

Since the cells on the edge of the grid don't have 8 surrounding cells, you should consider the grid as if horizontal and vertical edges are wrapped around, so that each cell has 8 surrounding cells. Please refer to the examples below to understand the concept

2 0 0 1 0 0
2 0 0 1 0 0
2 0 0 1 0 0
0 1 1 0 0 0
0 1 1 0 0 0
0 1 1 0 0 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 2 1 0 0
0 0 2 1 0 0
0 0 2 1 0 0
0 0 1 1 0 0
0 0 1 1 0 0
0 0 1 1 0 0
surrounding of cell (1,1) surrounding of cell (6,4) surrounding of cell (5,1)

Each cell survives (the value stays the same) or dies (the cell becomes bare ground) in the next generation (the generations are simulated with a for loop) depending on the state of the surrounding cells (the 8 cells described above) and the following set of rules:
• a prey cell dies for overpopulation if more than 3 of the surrounding cells are preys
• a prey cell dies for underpopulation if less than 2 of the surrounding cells are preys a bare ground cell with at least three prey cells in its surrounding becomes a prey in the next generation to simulate the process of re-population;
a prey cell dies if there is at least one predator in the surrounding cells and no other prey that can help to defend itself.
• a predator cell dies for starvation if there is no prey cells in its surrounding.

This is an example of 3 generations

2305_generations.jpg

You have to write a MATLB function that takes as input
• a 2D array that represents the initial scenario
• the number of generations and returns as output the evolved grid and the number of preys and predators alive at the end of the evolution process. The function, will implement the evolution of the system given the initial state and the number of generations.

At the beginning of your function you have to insert a check on the correctness of your inputs, namely
• the input 2D array needs to be square
• the input 2D array needs to be initialised with values 0-1-2, no other value is allowed
• the input number of generations needs to be positive
If any of the checks fails the function returns an error message to screen and exits by return- ing as output a scenario without preys or predators (zeros 2-D array) with number of preys and predators equal to zero.

Validation

This is an example that you can use to validate if your function works, where M is the input grid, 15 and 30 the number of generations used, G the evolved system, n the final number of preys and m the final number of predators:
>> M

M=
2 0 0 1 0 0
0 1 1 0 0 0
0 0 0 0 1 0
0 0 0 0 1 0
0 0 2 1 0 0
0 0 1 1 0 0

>> [G,n,m] =preypredator(M, 15 ) G=

2 0 0 0 0 1
0 0 0 1 1 1
0 1 1 0 0 1
0 0 1 0 1 0
0 0 2 1 0 0
0 0 0 0 0 0
n= 10
m= 2

>> [G,n,m] =preypredator(M, 30 )

G=

0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0

n = 3 m= 0

Reference no: EM133284213

Questions Cloud

What does arendt mean by immortality : What does Arendt mean by "immortality"? How does it differ from "eternity"? How do they each relate to politics?
Differentiate between line and staff functions : Differentiate between Line and Staff functions in an organization and discuss the possible conflicts that arise in the interaction bes officers or personnel
Important sources of political socialization : What do you think the most important sources of political socialization are in shaping our political value system?
Why do you think democracy is so fragile : Why do you think democracy is so fragile and prone to reactionary conservative and violent forces, as in the former Yugoslavia
Simulate a living system of predators-preys : ME108 Engineering Analysis and Numerical Methods - University of Strathclyde write a MATLB function the number of generations and returns as output
Explain history of the reconstruction finance corp : In 1932, Congress established the RFC with a limited mandate to provide emergency loans to banks, Explain History of the Reconstruction Finance Corp
Explain nature of queen power in buganda : Explain the nature of the queen's power in Buganda and explain the reasons behind the loss of women's political power in nineteenth-century East Africa.
Discuss the stock market crash : The United States entered World War II in 1941, the same year as the Great Depression, which lasted from 1929 to 1941. Discuss The Stock Market Crash
Ethic of ultimate ends and ethic of responsibility : Weber distinguishes between an "ethic of ultimate ends" and an "ethic of responsibility." What does he mean by each?

Reviews

Write a Review

Simulation in MATLAB Questions & Answers

  Calculate the stress intensity factor

Use the three-parameter zone finite element method or the boundary collocation method to calculate the stress intensity factor K, at the crack tip for the plate

  Build a simulation using newtons laws of motion

Build a new and different simulation of your own using Newtons laws of motion and Show the code and describe how it works

  Write the specification of load mover

Write the specification of LOAD MOVER detailed of the whole design and precise for automatic control section and divide the design into various modules and Is the kernel required if yes which one?

  Design the automatic control section using statecharts

Aim of this project is to design an embedded system which can move loads from one place to another. The system can be operated manually, automatically and wirelessly.

  Need an expert who can model a drill in simulink

Need an expert who can model a drill in Simulink. Working model of a drill needing for an improvment to behave more realistically as a drill to drill through plastic block.

  Project is on load frequency control using fpid

Project is on load frequency control using FPID tuned using GA and PSO algorithm and the system is a two area system.

  Number of packets received with time

Let x be the number of packets received with time -

  Build a matlab based graphical user interface

Build a Matlab based graphical user interface (GUI) that operates in conjunction with a base Matlab/ Simulink simulation program. Any base simulation is considered acceptable.

  Build a matlab based graphical user interface

Build a Matlab based graphical user interface (GUI) that operates in conjunction with a base Matlab/ Simulink simulation program. Any base simulation is considered acceptable.

  Simulate the standardised sum of independent

Simulate the standardised sum of independent and identically distributed variates - Fit a linear regression model as in Q5, and plot your estimates for β0 and β1 as N increases, together with a line indicating their true values. Supply your code.

  Plot the original periodic square wave

Plot the original periodic square wave on the same graph. Comment on the difference between the original periodic square wave and its truncated Fourier series presentation.

  Use matlab to plot the function

Plot the original periodic square wave on the same graph. Comment on the difference between the original periodic square wave and its truncated Fourier series presentation.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd