Lab Overview

Problem 1

For the first problem, we had to modify a predator/prey relationship simulation to record the number of each animal every second. We then had to export the data and create a line graph of it in Excel.

Problem 2

For the second problem, we had to make a sprite follow the mouse along the bottom of the screen, while a cloud above drops rain droplets. If they touched the sprite, it has to decrease in size and create a clone that bounces away. The game also has to end if you dodge 10 of the raindrops.

My Solution

Problem 1 Solution

For problem 1, I created a list that adds the rabbit or fox variable to it every second. I then exported the list and loaded them in excel. I created a line graph out of it and then took a screenshot of the graph so I could easily add it to my website as a .png.

Problem 2 Solution

For problem 2, I first started by setting the cat sprite to follow the mouse, but only on the x-axis. I then made the cloud quickly and moved onto the raindrops. I set them to always follow the position of the cloud, and be hidden while doing so. Then, every 0.5-3 seconds, it would create a clone of itself and fall towards the bottom of the screen. If it touches the cat sprite, it hides itself. Meanwhile, the cat sprite decreases in size by 10% and creates a clone that moves towards the top right of the screen. Finally, for every time a raindrop sprite hit the bottom of the screen, it adds 1 to the "miss" variable. When the miss variable equals 10, then another sprite, saying "You Win!" pops up on the screen.

Questions

What data is attached to each clone? That is, what is changed on each clone that allows for the rabbits and foxes to appear/disappear?

The clones get a new if statement which says that if it touches a fox, then it deletes the clone and changes the rabbits variable by -1. For the foxes, if their volume equals zero, they are deleted. The volume is controlled by how many bunnies they eat.

Are the simulation results the same each time? Why or why not?

No, because the fox and rabbits move differently every time, creating different results. In one simulation, the fox might eat 10 rabbits, in the second, however, it may only eat one.