Simple Python Games
Dabbling in Game Development
This game is a simple number guesser that randomly selects an integer number between 1 and 100. The application gives the player instructions on what to guess and checks the guess before checking the accuracy of the number. If the guess is not valid, the guess is ignored, and the player is instructed to try again.
In the original version of my game, the player is given ten chances to guess the number. I enhanced/extended the game to make the user choose the difficulty, which will affect the range and the number of guesses allotted to reach the number. The user will have to find the correct number between 1 and 20 in 5 attempts on the easy setting. The medium difficulty will be the same as the original version, but the hard difficulty will decrease the number of guesses to 5 for the range between 1 and 100.
The program uses the random
module as well as the
sys
module. The random module allows me to generate a
random number in the range of the difficulty previously mentioned. The
sys
module is used to change the final message's color to
red, so the user is visually cued that the game is over. I created this
program with simple logic commands in and without the use of any methods
and functions. These programs' source code can be found my personal
Github
and other codes described on this site.
The Tic-Tac-Toe game code is based on the code from Invent Your Own Computer Games with Python. This code uses many different methods to get a user to play against a simple computer artificial intelligence. The player first selects their "piece" of either X or O. The computer decides whether the computer or the user will go first in making moves. The computer prioritizes taking the corners, then the center unless the computer can win the game.
The game uses a simple python list to hold both the user and the computer's move choices. I added a layout of the spaces at the start of the program to help the user. After each game, the player is asked if they want to play again.
Dragon's Realm is another game that came from Invent Your Own Computer
Games with Python. I was interested in this game because it is entirely
a text-based game that initially made me think of Zork's classic
gameplay. The game uses the random
module and the
time
module. The premise of the game is for the user to
select between one of two caves to search. Both of the caves have a
dragon and a treasure, but the dragon is benevolent and will gladly give
the user the prize, while the other is a protective dragon that attacks
the user. The game randomly assigns the positive or negative cave. After
the user makes a selection, the story will begin with a short break of
two seconds between each storyline to tell the user what fate will
befall the adventurer.
Hangman is a classic game that allows people to solve a simple spelling game that inspired things such as Wheel of Fortune. The game uses a word bank made of types of animals. The game only accepts letters as guesses and checks the guessed letter to see if it has already been guessed. Unoriginal guesses are ignored, and the player is informed that the letter has been guessed in a previous round.