Artificial Intelligence Games

Guess the Number

We used Python to make a program where we can play a game. The object of the game was to guess the computer's number.

This is my code for the guessing game. When running, it looks like this:

Hangman

The next day, we started working on a hangman game.

After several tries, I managed to get the program to detect which letter goes where in the blanks.

Obstacles

At first, I tried to make several functions to organize my code. However, it did not work until I just wrote the code as a long chunk.

Although I got this part of hangman to work, I still could not get the hangman board to change after each wrong answer. It would show the head after one wrong answer, but it would not show the rest of the body after more incorrect guesses.

Also, I could not figure out how to determine the number of blanks based on the length of the word. As a result, I only used three-letter words in my hangman.

Overall, that is as far as I could go on my own.

Getting More Words

A handful of words isn't enough for my hangman game, so I imported a list of animals.

Tic Tac Toe

We created a tic tac toe game in Python.

I started writing the functions I would need to run the game and then I filled each function with the appropriate code.

I combined all the functions to create the game's loop.

Once I ran it, I was able to make a two-player tic tac toe game. I still haven't figured out how to make it repeat or include the computer's turns.

Obstacles

Once I got the board and the numbers to replace itself with x's and o's, I couldn't get the win function to work. I used an if statement but I still couldn't figure out how to make it work with an if statement instead of using "return."

Also, I couldn't get the board to reset today.Once prompted with "Play again?" the player would input their choice into the old board instead of a clean one.

The next day, I was able to get the Tic Tac Toe game to replay.

The only problem is that the program doesn't ask the user if they want to play first. In this example, the computer goes first without asking the user.