Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 pLastnameFirstname.py as required above.
Take the preypredator 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.hunttime clock ticks starting with
the Human objects creation time if a Prey is in a neighboring cell using checkgrid 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.starvetime class attribute, initialized in main
A Human object breeds like an Animal object, with the breeding period given by a
Human.breedtime 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
initanimals
should take each an
extra parameter
counthumans
and
initanimals
should position Human objects at random
positions.
A method
counthumans
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 its 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 Humans superclass.
Use the objectoriented 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
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