CSC160 Programming Assignment 6: Tic-tac-toe (Optional)
Contents
Overview
This is an optional assignment. The purpose of this assignment is to leverage the skills you've learned this semester to make a terminal-based tic-tac-toe game. The game will be one-player (x's), with the program AI (o's) taking over the second player. Your program should behave as follows: first, you randomly decide whether the player or the AI goes first. Then the AI and player alternate until one of them gets three in a row vertically, diagonally, or horizontally. The grid is 3x3. When it's the AI's turn, you should systematically (easy), randomly (medium), or strategically (hard) pick an empty cell in which to place the AI's O. The user will pick a spot by entering the coordinates, e.g., 0 0
corresponds to the upper left, while 2 2
corresponds to the lower right. The user should be prompted until the coordinates entered correspond to an empty cell. The game board should be printed out after every move made by either the player or the AI. Make good use of functions for this!!
A few notes on the AI's selection scheme. The systematic approach just walks down the grid and selects the first empty spot. This is boring and predictable. In the random approach, the AI randomly selects a row and column until an empty cell is found. This is boring, but not as predictable as the systematic approach. The strategic approach is the most interesting, and the AI needs to figure out how to prevent the player from achieving three in a row, as well as try and make three in a row for itself. So try and place an O in a cell if it will either give the AI three in a row, or if it will prevent the player from getting three in a row on the player's next turn.
Note: No late days will be accepted.
(Back to top)Requirements
- Everything below is contingent on the game compiling and working. If it doesn't compile, or it doesn't run, then no points will be given
- Who goes first is randomly selected (1 point)
- The interface (what's displayed in the terminal, and how the user interacts with it) is attractive and easy to use (1 points)
- The game ends when someone gets three in a row (1 point)
- The AI's selection strategy is systematic (1 pt), random (2 pts) or strategic (3 pts)
- Uses functions appropriately (2 points)
- Has good documentation and a header (1 point)
- Make sure to follow the style guidelines (1 point)
Submissions
Everything should be uploaded to Canvas by the deadline posted. No late days will be accepted.
(Back to top)