Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python class to simulate an ecosystem containing two types of creatures, bears and fish. Please!!!! Read the question carefully! There is no comparision

Write a Python class to simulate an ecosystem containing two types of creatures, bears and fish.

Please!!!! Read the question carefully! There is no comparision about strength and gender!!!!!!!! Please do not copy some answers which do not actually fit my question. Thanks for your help.

image text in transcribed

Write a Python class to simulate an ecosystem containing two types of creatures, bears and fish. The ecosystem consists of a river, which is modeled as a relatively large list Each element of the list should be a Bear object, a Fish object, or None. In each time step, based on a random process, each animal either attempts to move into an adjacent list location or stay where it is. If two animals of the same type are about to collide in the same cell, then they stay where they are, but they create a new instance of that type oi animal, which ls placed ?n a random empiyu.e", previously Norie location ln ihe list. If a bear and a fish collide, however, then the fish dies (i.e., it disappears) Write an initializer for the ecosystem class, the initializer should allow the user to assign the initial values of the river length, the number of fishes and the number of bears. Before the simulation, fishes and bears should be allocated randomly into the river. The ecosystem class should also contain a simulation() method, which will simulate the next N steps of the random moving process. N should be inputted by the user. In each step of your simulation, all animals in the river should try to take some random moves. For example, assume that before the simulation, the initial state of the river is: NNFNNNBNBNN In which, 'F, 'B' and 'N' denote fish, bear and empty location respectively. Assume that in the first step of simulation, the first fish will move to the left, the first bear will move to the right, and the second bear will remain still. Then after the first step, the state of the river is: NFNNNNNBBNN

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Describe the undesirable behavior.

Answered: 1 week ago

Question

Does your family have a "motto" - spoken or unspoken?

Answered: 1 week ago