|
|
Javascript Tic Tac Toe
|
| Article by: | Premshree Pillai (10/10/2002) |
|
| Sponsored by: |
Neil Matthews Hypnotherapy, Wilmslow |
| Summary: | Play against the computer and learn a crafty bit of Javascript with this simple game. |
|
| Viewed: 27322 times |
Rating (375 votes): |
|
5 out of 5 |
|
|
|
Javascript Tic Tac Toe
View Online Demo
Download Project (11KB)
The game is written in JavaScript and works with IE 5+/NS 6+.
The Rules of the game are simple :You win if you get a complete row or complete column or any complete diagonal.
The game has been written in such a way that, the computer always tries to block the player's path. This is how the Game works :
First select who plays first.
When the computer plays it's first move, it tries to place its token("0") in a diagonal position.
In the course of the game, the computer analyses the number of rows, columns and diagonals with maximum number of the player's token("1"). If the computer already has a token in a particular row/column/diagonal, it gives that particular row/column/diagonal a low preference.
Thus it analyses the row/column/diagonal with maximum player's token and then places it's token in one of the empty spaces in that row/column/diagonal. A row/column/diagonal which is full is given low preference.
We'll put the main javascript here on the page, but to experiment with the entire project, we recommend downloading the zip file above and seeing how the various elements interweave.
|
|
View highlighted Comments
User Comments on 'Javascript Tic Tac Toe'
|
|
|
Posted by :
Archive Import (Jan) at 13:16 on Sunday, December 22, 2002
|
Thanks for the game, I love it. Its just what I have been looking for my site.
| |
Posted by :
Archive Import (rylon) at 12:43 on Friday, May 09, 2003
|
can sum1 send it to me where i dont have to take out or enter stuff i am useing geocities pagebuilder(i im 14 trying to learn how to make a cool site for my friends)
| |
Posted by :
Archive Import (Dan) at 05:18 on Tuesday, July 29, 2003
|
If you select centre, centre top, top right, centre right you win every time!
| |
Posted by :
k111 at 14:31 on Friday, January 16, 2004
|
i cant make it work in "Ready to Program" which i need it to work for my assignment...can u help me??
| |
|
To post comments you need to become a member. If you are already a member, please log in .
| |