Inspiration

When we started, we wanted to make a game that involved running away from an enemy, and we thought of BitLife. More specifically, we thought of the minigame in BitLife where you try to escape an enemy on a 2D grid while they chase you. So we thought, what would make it more useful? What if we implemented a math system to help train your math skills? Math can be very tedious if you're looking at it only, especially for a prolonged time, so we sought to make this a bit more engaging.

What it does

The program works by prompting the user to select a difficulty - the more difficult, the more enemies and obstacles there are. The user wins by moving towards and reaching the target destination (marked by a green box on the map). In order to move, the user must answer one of the aforementioned questions. The longer the game goes on, the harder the questions become (Basic Algebra -> Advanced Calculus). The enemy moves using the A* Algorithm. The A* Algorithm checks all four cardinal directions, running a series of math equations to determine which one gets closest to the user. If there is a tie in judgement, a tiebreaker occurs whereby the same process is repeated for these two directions.

How we built it

The core functionality of the game was made using PyGame. PyGame was used to create not only the graphics but also some of the logic behind it. To implement the randomness of the math questions (to prevent it from being too predictable), we used the Random library to scramble the numbers. The Heapq library was used to help implement the AI logic of our enemy, the A* algorithm.

Challenges we ran into

As it was our first time using PyGame, and considering we never built a searching AI, there were many challenges we ran into. First and foremost, implementing the AI was extremely difficult, as the logic of the A* Algorithm felt a bit unclear at times. We eventually used AI to help flesh out the logic, rewriting several parts of the code so that it would work as intended. Another issue that we faced was that our AI had a habit of teleporting places, which was the result of several logical errors in our code. We fixed it by implementing checks that prevented multiple turns from being taken by the AI when only one turn should've been taken.

Accomplishments that we're proud of

We're proud of having been able to implement most of our original vision for our game, though we were not able to implement all of our ideas. The many bugs that showed up and were fixed were a great point of pride, due to the endless frustration they caused. With these bugs, our game would be unplayable, but overcoming these issues ensured that our game would work as we'd always intended.

What we learned

We were able to learn how to utilize PyGame and Python game development from this project. We were also able to learn about the A* Algorithm for searching on a 2D grid. Most importantly, we learned how to implement these different libraries to work in tandem with each other while creating as little conflict as possible.

What's next for Simple Math Project

Built With

Share this project:

Updates