User Tools

Site Tools


logolib:tictactoe

Runs on Terrapin Logo 4 Runs on Terrapin Logo 3

Tic Tac Toe

Tic Tac toe American Embassy School Grade 9 student Manit developed the classic Tic Tac Toe game in Terrapin Logo as a contest between the computer and a human player. The person goes first, clicking on a square to mark it with an X. The computer follows playing the O role. Manit has programmed the computer to be a clever Tic Tac Toe player and hard to beat.

This program utilizes basic artificial intelligence in Terrapin Logo to provide the computer strategy. Classic turtle graphics are used to draw the Tic Tac Toe board. Interaction is achieved by reading the mouse location and button status.

Manit explains the testing procedures used in developing the program.

I ran several tests on this game, first I played like a novice and saw if the computer could actually win, this test proved to be successful. Then gradually I improved my level of play and saw whether the computer could block of corner tricks etc.

Another test I ran was I played each square and saw whether the computer would play the square it was supposed to, this was tedious but it was a must I also tested for the clicking function. This proved to me a major head ache because I had changed the origin so it proved to be a bit tricky as the co-ordinates of the board and mouse were different. In the end it worked out.

Start Terrapin Logo, and load them into workspace or into an editor and use Edit/Define to define them into workspace. Alternately, open an editor, and paste the procedures into the editor. Then define the procedures with Edit/Define. Type TICTACTOE to begin and see if you can beat the strategy Manit developed for the computer player!

TicTacToe.lgo
Procedure:
TICTACTOE
Description:
Play Tic Tac Toe against the computer
Level:
Intermediate
Compatible:
Logo 3, Logo 4
Tags:
Game, Tic Tac Toe
logolib/tictactoe.txt · Last modified: 2018/08/27 03:39 (external edit)