Short 2 player TicTacToe program
Author |
Message |
A.J
![](http://compsci.ca/v3/uploads/user_avatars/119833057151651227b0d87.gif)
|
Posted: Mon Nov 02, 2009 7:59 pm Post subject: Short 2 player TicTacToe program |
|
|
The program (about 20 lines) allows two players to play Tic Tac Toe. I store the board into one number, by representing 'X' with the binary for 1, or '01', 'O' with the binary for 2, or '10', and a blank for the binary for 0, or '00'. Each square is represented by two bits.
I check for wins by 'or'ing it with different winning positions.
How it works is you enter a number from 1->9 (inclusive) to play a move:
1 2 3
4 5 6
7 8 9
1 represents the top left corner, 2 represents the top middle square, etc...
I took out things like error checking, as I am assuming you will enter a number from 1 - 9 and that you are going to play on a square that hasn't been played on before (It is just adding 3 additional lines, anyways).
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
Cool TicTacToe.t |
Filesize: |
610 Bytes |
Downloaded: |
327 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|