Case Study 3:
1. def mainSimulation() :
2. numberOfBears = 10
3. numberOfFish = 10
4. worldLifeTime = 2500
5. worldWidth = 50
6. worldHeight = 25
7.
8. myWorld = World(worldWidth, worldHeight)
9. myWorld.draw()
10.
11. for i in range(numberOfFish) :
12. newFish = Fish()
13. x = random.randrange(myWorld.getMaxX() )
14. y = random.randrange(myWorld.getMaxY() )
15. while not myworld.emptyLocation(x, y) :
16. x = random.randrange(myWorld.getMaxX() )
17. y = random.randrange(myWorld.getMaxY() )
18. myWorld.addThing(newFish, x, y)
19.
20. for i in range(numberOfBears) :
21. newBear = Bear()
22. x = random.randrange(myWorld.getMaxX() )
23. y = random.randrange(myWorld.getMaxY() )
24. while not myWorld.emptyLocation(x, y) :
25. x = random.randrange(myWorld.getMaxX() )
26. y = random.randrange(myWorld.getMaxY() )
27. myWorld.addThing(newBear, x, y)
28.
29. for i in range(worldLifeTime) :
30. myWorld.liveALittle()
31.
32. myWorld.freezeWorld()
-Refer to the session in the accompanying Case Study 3. On what lines does most of the simulation work take place?
A) 2-9
B) 11-18
C) 20-27
D) 29-30
Correct Answer:
Verified
Q9: Case Study 1:
1. class Fish:
2. def _init_(self):
3.
Q10: Consider the bears and fish simulation presented
Q11: What built-in function asks if an object
Q12: Case Study 2:
1. def liveALittle(self):
2. self._breedTick =
Q13: Case Study 2:
1. def liveALittle(self):
2. self._breedTick =
Q15: As you consider the implementation for the
Q16: The complexity of a computer simulation is
Q17: In the simulation of bears and fish
Q18: When creating objects, the list of things
Q19: Removing a life-form from a simulation world
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents