A Simple Tic Tac Toe Program

ttt is a simple tic tac toe game for ASCII terminals. You can download the source code of the current version.

A Sample Session

+--------------------------------------+
| Welcome to tic-tac-toe version 1.0.1 |
+--------------------------------------+

Choose one of the following:

  (1) human vs. human
  (2) human vs. computer
  (3) computer vs. human
  (4) computer vs. computer

  (8) show the rules
  (9) quit the game

Your choice? 8

The rules:
----------
Place 3 stones in a row to win (horizontally, vertically or diagonally).
Player 1 uses x, player 2 o.
Enter x and y coordinates seperated by whitespace (range 1-3).
Example: 2 2 [places stone in middle field]

Choose one of the following:

  (1) human vs. human
  (2) human vs. computer
  (3) computer vs. human
  (4) computer vs. computer

  (8) show the rules
  (9) quit the game

Your choice? 4

Playing a game computer vs. computer:

      1   2   3

  1     |   |   
     ---+---+---
  2     |   |   
     ---+---+---
  3     |   |   

Player 1 (x) is controlled by the CPU... :-)

      1   2   3

  1     |   |   
     ---+---+---
  2     | x |   
     ---+---+---
  3     |   |   

Player 2 (o) is controlled by the CPU... :-/

      1   2   3

  1   o |   |   
     ---+---+---
  2     | x |   
     ---+---+---
  3     |   |   

Player 1 (x) is controlled by the CPU... :-/

      1   2   3

  1   o |   |   
     ---+---+---
  2     | x |   
     ---+---+---
  3     |   | x 

Player 2 (o) is controlled by the CPU... :-/

      1   2   3

  1   o |   | o 
     ---+---+---
  2     | x |   
     ---+---+---
  3     |   | x 

Player 1 (x) is controlled by the CPU... :-P

      1   2   3

  1   o | x | o 
     ---+---+---
  2     | x |   
     ---+---+---
  3     |   | x 

Player 2 (o) is controlled by the CPU... :-P

      1   2   3

  1   o | x | o 
     ---+---+---
  2     | x |   
     ---+---+---
  3     | o | x 

Player 1 (x) is controlled by the CPU... :-/

      1   2   3

  1   o | x | o 
     ---+---+---
  2     | x |   
     ---+---+---
  3   x | o | x 

Player 2 (o) is controlled by the CPU... :-(

      1   2   3

  1   o | x | o 
     ---+---+---
  2   o | x |   
     ---+---+---
  3   x | o | x 

Player 1 (x) is controlled by the CPU... :-(

      1   2   3

  1   o | x | o 
     ---+---+---
  2   o | x | x 
     ---+---+---
  3   x | o | x 

The game is a draw.

Choose one of the following:

  (1) human vs. human
  (2) human vs. computer
  (3) computer vs. human
  (4) computer vs. computer

  (8) show the rules
  (9) quit the game

Your choice? 9
    

back to my homepage.