Posted: 21st Jun 2003 13:47
I've written a fairly simple Noughts and Crosses game.

I'm attaching the code. Feel free to do whatever you want with it. If you make any really cool improvements to it, please let me know on philipyoung@netvigator.com
Posted: 21st Jun 2003 19:00
it dosen't work. also u put to many spaces. like X + 3 = 2 just make it X+3=2 or whatever. u don't need spaces
Posted: 22nd Jun 2003 0:07
Sorcre:

Too many spaces? That's the silliest thing I've ever seen said on a forum in a while.

Using spaces improves the readability of code, and makes it easier to follow.

-Misanthrope
Posted: 22nd Jun 2003 7:24
No, "too many spaces" should be a good thing.

It works fine for me. Here in the US, we call it "Tic Tac Toe". The control is surprisingly effective. Maybe you could make it a little bigger though.

I beat it. Here's a winning combination:
5,3,9,1
Posted: 22nd Jun 2003 21:17
Changed it so the ai fills the corners first in a random order insted of the first blank it comes too.
Posted: 23rd Jun 2003 17:28
Er... I think it does work and I see from this forum and the discussion forum that its working on some other people's 'puters.

Also a "Big Up" and "Respect" to Andrew11 and The_Winch for:

a. managing to beat it (never spotted that one Andrew11 - well done!)

b. fixing that, er, bug (good bit of code there The_Winch)

respectively.

Now I am going onto something much, much more ambitious. I'm going to see if I can port Christian Pinder's Elite: TNK code from C/Allegro to DarkBasic Pro. If I can, then I'm going to make some fairly serious modifications to it so finally PC players will have an ArcElite-like experience.

Phil
Posted: 23rd Jun 2003 17:41
Actually, having just compiled the amended code, The_Winch, and I mean no offence here, but it seems to have introduced another bug. For some reason every few games I've noticed that the computer skips a move.

Possibly this bug was in my original code. Anyway, I'll have a look at the code again this weekend coming and see what is going on.

Cheers

Phil
Posted: 23rd Jun 2003 20:44
I think it might be this line
text 0,0,str$(random) : wait key
I was using it to check the random numer generation was working correctly and forgot to remove it.
Heres the code with the offending line removed and hopfully fixes the problem.

It might be an error elsewhere in my code but I can't see it.
Posted: 24th Jun 2003 5:10
dang i tried ur game out and every march was a draw!

Posted: 24th Jun 2003 17:55
Great! That shows the computer is playing as well as it can.

Remember that Os and Xs should always end in a draw when played by two players of equal intelligence. Thats why its a pointless game.

Also, thanks to The_Winch for sorting out that bug. I've modified my original source code to formally credit him for his amendments. Only fair, after all.

Phil