View Full Version : Tic-Tac-Toe

10-05-2002, 05:01 PM
Just wrote the Tic-Tac-Toe game in JavaScript with support for multiple board sizes.

Check it out here :


10-05-2002, 05:48 PM
I just won, then the comp still had it's turn and alerted me it was a draw.

10-05-2002, 07:08 PM
the same thing happened to me, i won but the comp got one more turn and won the game

10-05-2002, 07:21 PM
The computer does not recognize I won already when completing a 3 fields row on a 3x3 board. How frustrating.

To reproduce:

Select 3x3 board, player plays first. x shall be the number of fields from the left edge (1-3), and y the number from the bottom edge (1-3).

1. I set my mark directly in the middle (x:2, y:2)
2. Computer sets in the bottom right corner (x:3, y:1)
3. I set my second mark at the upper left corner (x:1, y:3)
4. Computer sets in the middle of the upmost row (x:2, y:3)
5. I set my third mark at the middle of the first column (x:1, y:2). Hah! Now I've put the computer in the corner. Doesn't matter where he sets, he can't prevent me from completing a row/column next time I move.
6. Computer sets at x:3, y:2. Prevents one row, but he's lost anyway.
7. I set my glorious last mark at x:1, y:1, expecting a cheering crowd... but what's that? The computer is allowed to set a mark immediately again and completes his column (x:3 y:1,2,3), and an alert tells me I've lost...

that's unfair!

10-05-2002, 08:50 PM
In the previous one, I never tested for a condition when the player wins!

I modified the code....... and now the player can win.

Check it out at :

Please let me know, if anything else is wrong.


10-06-2002, 07:12 AM
no errors now but i can't seem to win on any other size than 3x3, only because I suck nothing with the program

10-06-2002, 07:25 AM

10-09-2002, 08:55 PM
(3x3 mode)

when you select "computer first" the first game it goes first, but then when you play again after the game you must go first ... not really much of a problem just thought i would bring it to your attention.

also, the computer beat me and it said it was a draw (3x3 mode, computer first)

and just a question, why 1 and 0 ?

10-10-2002, 01:21 PM
No reason for '1' and '0' :)
It doesn't matter anyways!

10-10-2002, 02:13 PM
Could you give me the move list ?

10-10-2002, 11:20 PM
i experienced the same thing; you select computer goes first, and after the first game, the i had to go first every time. also, i'm still running into the problem where sometimes, if i win, the computer gets an extra turn. except for me, the computer called it a draw, instead of a win.

10-11-2002, 03:23 AM
Could you give me the move list ?

if the move list matters that much, then i cant reproduce it, i dont remember what i did sorry :(

i know 1 and 0 dont matter, just asking hehehe

keep up the good work :) i like it

10-11-2002, 07:42 PM
joh6nn, I had updated my script. It's at :

Are you getting the problem at this URL ?

10-11-2002, 08:21 PM
Originally posted by joh6nn
i experienced the same thing; you select computer goes first, and after the first game, the i had to go first every time.

Just updated the script. Check it out at :


10-11-2002, 09:00 PM
Works Great :D

10-11-2002, 09:15 PM
i played the game (computer first) then played again using the play again option. then i played and got a grid
nobody had won and it didn`t say this, it was just like that grid i showed above.


10-14-2002, 12:40 PM
Try playing it here :


10-20-2002, 01:28 AM
i did what scroots said and he is right, also on that last link whenever you hit play again it lets you go first.

11-09-2002, 09:09 AM
Found another little bug. It should be a draw on 4v4 but it didn't alert me. Here is the move list:


And I went first.

Just thought i'd bring it to your attention.

11-25-2002, 05:40 AM
I just wrote a Perl version of the game.....
Find it here : http://qiksearch1.tripod.com/cgi-bin/tic-tac-toe.pl


08-07-2003, 08:50 PM
Hi, I just played your perl Tic-Tac-Toe (because the other one dosn't seem to work...)
I just won at Tic-Tac-Toe, I didn't think it was possible to win at that game. But how can I make the computer go first?

09-14-2003, 01:19 AM
I'm getting a dead link for your JS version...

09-14-2003, 02:17 AM
mine or his?

09-14-2003, 02:36 AM
Originally posted by shlagish
mine or his? you don't have one. :D

09-14-2003, 04:14 AM

I have one but I only posted it in another thread, lol, I was confusing threads.

09-23-2003, 10:26 PM
Please update the JS version, I played the Perl version but it couldn't beat me ;)

09-26-2003, 12:04 AM
I was playing your Perl game and the computer got 2 in a row. So rather than block it, I also got two in a row. The computer had the opportunity to win but it didn't, it blocked me rather than moving in for the kill.

It's a pretty good looking game, but now that you've made it you might want to start working on a little AI to make it a bit more tricky.

09-26-2003, 12:29 AM
Have you tried to put the difficulty setting to the hardest?

09-26-2003, 12:36 AM
If you're referring to the JvaaScript version I can't play that because all the links leading to it are dead.
If you're refering to the Perl version that I can't see anywhere to change the difficulty level.

09-26-2003, 12:55 AM
oh, I'm sorry, I must be mixing up something because I can't get to the javascript version either

09-27-2003, 10:03 AM
For all wanting to play the JS version...

found it :)


Dunno if that's the same one.

09-27-2003, 02:08 PM
Good game and almost impossible to win on a 5x5 board. However it still tries to block me rather than win, (sometimes).

09-27-2003, 07:48 PM
Ok I played this (http://premshree.resource-locator.com/javascripts/tic-tac-toe/index.htm) one, and I did exactly what mordred did, and it says:

A Runtime Error has occurred.
Do you wish to Debug?

Line: 567
Error: Out of stack space

I click No and it says:

Stack overflow at line: 0

I click OK and it does nothing. I'm using IE6 SP1. Perhaps the one I played wasn't the latest version?

Also after that, I can still click in the empty space in the bottom middle, and it says:

A Runtime Error has occurred.
Do you wish to Debug?

Line: 446
Error: Out of stack space

Again, I click no, and it again says:
Stack overflow at line: 0

Edit: I found another version at http://www.geocities.com/e_i_search/premshree/web-include/pub/scripts/JS/tic-tac-toe/, and that doesn't happen anymore, but now when I load the page it says:

A Runtime Error has occurred.
Do you wish to Debug?

Line: 39
Error: Object Expected

So I click no, and it says,

A Runtime Error has occurred.
Do you wish to Debug?

Line: 1
Error: Syntax error

Other than that, it works fine.

Edited again: I think it's because of it being on a different site...

And again: Here (http://www.google.com/search?q=premshree+tic%2Dtac%2Dtoe)'s where I found the geocities one, by the way.

09-27-2003, 08:55 PM
Not getting any errors with WinIE6. What browser are you running?

09-27-2003, 09:05 PM
I guess you missed it in my post. I'm using Microsoft Internet Explorer version 6 SP1 (6.0.2600.0000.xpclnt_qfe.021108-2107) and Windows XP Professional.

09-27-2003, 09:08 PM
Well apart from the fact I've got 6.0.2800, and I've XP Home, I've got exactly the same browser.

In conclusion, how odd.

No idea what's wrong.

09-27-2003, 09:19 PM
Yes, how odd.

09-27-2003, 10:01 PM
Well, I get almost the same errors as DemonThing3, except with lines 568 and 447.
I've got XP Home and IE 6.0.2800.1106.xpsp2.030422-1633IC. I'll try it with a few other borwsers (Opera, Mozill etc.) see if it works for those.

09-27-2003, 10:08 PM
Yeah, the error isn't just IE only, it pops up on Opera 5.02, 6.00 & 7.11, NN 6.22
I also have NN 4.79, 7.02 & 7.10, Moz 1.4 & Moz FB 0.6 but I didn't try it on those.

09-27-2003, 10:09 PM
I see. That is very odd.

me', which version were you looking at?

09-28-2003, 10:20 AM
Both of the versions provided in DemonThing3's post worked for me. I don't even get the script error icon at the bottom. Is no-one else getting this error?

10-25-2003, 08:10 PM
i would like to check ur game out but the link doesnt work :confused:

11-15-2003, 07:45 PM
mhhh... the page isnt found when i open it why?