For this project, we programmed probability-based games in either StarLogo Nova or Scratch. Both of these are programs that used "block coding", which is when you drag and drop different blocks that represent compact bricks of code. We examined mathematical concepts like disjointed events (when the outcome of two events do not affect each other) and conditional probability (when the outcome of event A allows event B to happen). We learnt about them through class notes and worksheets that examined probability through different scenarios. Overall, the project developed computational thinking, programming skills, and probability concepts.
Benchmark #1: Concept
"i. I chose to do Snake because it’s a game which seems to be simple, but when I begin to think about how to make it it gets more and more complicated, so I hope it’ll be challenging.
ii. In Snake you control a block that is constantly moving, called the snake, with the arrow keys and try to “eat” food that randomly spawns on the field. Every time the snake eats some food it becomes longer, so the objective is to survive as long as you can without eating the wall or your own tail.
iii. I’m not super familiar with SL Nova, but I’d imagine you’d have to program the food as a randomly spawning agent that, when touched, would add 10 points to the score, respawn, and make the snake longer. The snake would be the most difficult aspect of the game to program because to needs to be able to grow by at least 1 unit every time it eats some food.
iv. I think getting the snake to grow will be really difficult because when it grows a block has to be added on as opposed to it just growing. Additionally, I think that getting the snake to move constantly could also be difficult."
Benchmark #2: Description
"My game will be played in scratch
i. When the player begins the game, the snake will spawn in the middle as one block, and the food will spawn at a random location on the field. As soon as the player hits one of the arrow keys, the snake begins to move. Every time the snake eats a piece of food it grows by one block and the food respawns at a different, random location. Additionally, the score goes up by 10 every time the snake eats a piece of food.
ii. The main probability analyses will be questions akin to “What is the probability of two pieces of food spawning right next to each other” or “What is the probability of food spawning on the edge”. "
Benchmark #3: Probability Analysis
For this benchmark, we examined the different probabilities of aspects of our games. The question me and my partner focused on was "What is the probability of a piece of food spawning next to the space that was occupied by the food that spawned before it, given that the first piece spawned on the edge of the field?". The first thing I did was figure out how the playing field works.I established it as a 10x10 field where the snake spawns in the middle, then the food spawns randomly in the middle. Then, I established that the probability of the first food (Pr[F1]) spawning on the edge of the field is 1/36. No matter where on the edge it spawns, there are only three possible spaces for the second food (F2) to spawn so that it would be next to where F1 was. This goes down to two spaces when you take into account that the snake will have to be occupying one of the space in order to eat the food. So, there is a 1/36 chance of F1 spawning on the edge, and then a 2/98 chance of F2 spawning right next to F1 (2 because of the two available spaces, and 98 because it can't spawn on the snake, which is occupying 2 blocks). So, the probability of both the events happening is (1/36)*(2/98)= 1/1764!
Benchmark #4: Program
My game is quite simple. Just press the green flag in the top of the screen and the snake will spawn in the middle, the food (a red block) will spawn randomly. As soon as you press the flag, the snake will begin moving so act fast! Press the arrow keys to control the snake and try to eat the food. Each time the snake eats, it grows by one block, so avoid biting your own tail!
All in all, I think I did pretty well in this project. I didn't really know how to code coming in, and I was really intimidated by it so I'm proud that I was able to make a successful program. My partner and I went through a few different (unsuccessful) project ideas at the beginning, but we pulled through and made a successful product. I'm also really proud that I was able to understand some of the more complicated aspects of my program to make something that worked. Additionally, I found it hard to