Question: Problem 2 This is the file name you would need testif.py Write the code for this problem in a file named p 3 _ Lastname
Problem
This is the file name you would need testif.py
Write the code for this problem in a file named p
Lastname
Firstname.py
as required above.
Take the prey
predator problem described in Chapter
and add
humans
Start from file
program
py
attached to the assignment page.
A human
is an animal
that kills and eats
only prey
and also moves and breeds like an animal. Humans
do
not
kill predators.
Here are the detailed rules pertaining to humans:
A Human object moves like an Animal object on the island grid.
A Human object does not kill predators.
A Human object eats Prey objects periodically. Every Human.hunt
time clock ticks
starting with
the Human object
s creation time
if a Prey is in a neighboring cell
using check
grid
the
Human will move to its cell and remove the Prey from the island, in the same way as Predators eat
Prey objects.
A Human object
starves
and is removed from the island if it has not killed a Prey within a
starving time given by a Human.starve
time class attribute, initialized in main
A Human object breeds like an Animal object, with the breeding period given by a
Human.breed
time class attribute, initialized in main
All other rules for Prey and Predators remain in effect.
We want to study the impact of humans on the island animal populations. Add the following to the
Island class:
Proper initialization for Human objects. The constructor and
init
animals
should take each an
extra parameter
count
humans
and
init
animals
should position Human objects at random
positions.
A method
count
humans
that returns the number of Human objects on the grid.
The
main
method should:
Take extra parameters for the Human class attributes described above and should properly
initialize them.
Keep track of the Human population for each clock tick in the same ways it
s done for Predator
and Prey objects.
Stop the simulation after
time units.
Display at the end with matplotlib the evolution in time of the Prey, Predator, and Human
populations.
Display the island grid to the terminal, at the beginning and at the end of the simulation.
More requirements:
Add a Human class to the existing class hierarchy so that code is properly reused. Use the
problem description above to decide what class is Human
s superclass.
Use the object
oriented design process. Integrate class Human smoothly into the existing design
and code.
Print a Human object on the Island grid with character
H
Apply the proper coding style and techniques taught in this class.
Run the program with different combinations of parameters and find an interesting case.
Take a screenshot
with the matplotlib chart showing the evolution of the three populations vs
time. Insert this screenshot in the Word document. This chart looks like that on slide
in the
Chapter
lecture notes PDF flle.
Take a screenshot
with the terminal showing the island grid printout
first tick and last tick
any other statistics displayed in main
Insert this screenshot in the Word document plz type code to run and include the testif.py
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
