My guessing game! I made this game because I was curious what it would look like to make a computer guess a number without using AI (spoiler alert, its a lot of if statements). My code runs a complete guessing game where you the player can guess, or you can have the computer guess your number!
I purposefully wanted no AI to be involved in the making of my code. The only AI I used during the process was chatgpt when I got super stuck on debugging.
numpy, guizero, pillow
There are two ways to run this code without having to run the source code yourself. If you are on windows or linux, I have an executable file you can run. If you are on Macos, there is a file that will run in terminal, but its a little more complicated for you. Fear not, I have instructions no matter what you may be doing.
Windows and linux executable file - In order to reach this executable file you need to go to my github (caitykat, repository is guessing_game). Navigate to the release v.1.0.0 (windows). Within this release you should see a file “guessing_game.zip”. Within this zip file is the executable file. Double click on the application and the game should run! Enjoy!
MacOS terminal - In order to reach this file you need to go to my github (Caitykat, repository is guessing_game). Navigate to the second release v.2.0.0 (macOS). Within this release you should see a file “guessing_game.app.zip”. Double click on this file to download it and try to open it. One of two things may happen. It will either open the game and there you go! If this doesnt happen and instead the computer blocks it from running, this is an easy fix. Go to your system settings. Find privacy and security and scroll to the bottom. You should see a part that says ““guessing_game” was blocked to protect your mac.” Click open anyways and input your password. Then boom! The game is running. Enjoy!
Running the source code locally - In either of the releases the source code is provided. This, or its just included in the files of the github page. Install one of the source code zip files and find the “guessing_game.py” file. This is the code you need to run it. I have the dependencies listed above and you will need all three to ensure the code runs correctly. Guizero is the most important as the entire app is made using it. In order for guizero to run, you also need numpy and pillow. There are plenty of tutorials online on how to instal this. Run it locally on your computer and enjoy!
Only shown once in the game, press the start button to get started with the actual game
Two buttons, one for computer guesses and one for Player guesses. Self explanitory, in the computer guesses the computer guesses your number, in player guesses you guess the computers randomly generated number.
This is a program I built based on enitrely if statments. I drew out the flow chart of how the numbers should be called for the most logical deduction (for example, guessing 50 first to cut the 100 pool in half) and from there typed out every if statement. The computer can accurately guess any number 0-100.
Higher button - Press when your number is higher than the number displayed,
Lower button - Press when your number is lower than the number displayed,
Correct button - Press when the number is correct
This is the screen that displays after the computer guesses the correct number.
It displays: What your number was, How many guesses it took, A button that when pressed will take you back to game mode select
This program has the player guess the computers number and see how many tries it takes them.
TextBox - This is where you enter your guess. Please type in a number. If you do not type in a number 0-100, nothing will happen.,
Submit - Press this button to submit your guess. If incorrect, the computer will say higher or lower. If correct, it will take you to a screen that says you won and how many tries it took.,
This is the screen that displays after the player guesses the correct number.
It displays: How many guesses it took, A button that when pressed will take you back to game mode select