Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Noughts and Crosses game (complete programme)

Author
Message
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
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
sorcre
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: United States
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

think of your plans as a man of action and act out your plans as a man if thought.........
Misanthrope
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location:
Posted: 22nd Jun 2003 00: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
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 22nd Jun 2003 07:24 Edited at: 22nd Jun 2003 07: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

"All programmers are playwrites and all computers are lousy actors" -Anon
Click Here!!!
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
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.
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
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

Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
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

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 23rd Jun 2003 20:44 Edited at: 23rd Jun 2003 21:12
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.
MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 24th Jun 2003 05:10
dang i tried ur game out and every march was a draw!



http://www.freewebs.com/goldenrodproductionstudio/index.htm
Yes that's right folks, another total revamp of my site.
Currently trying to register domain name, and get some copyrights.
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
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

Login to post a reply

Server time is: 2024-04-25 21:47:38
Your offset time is: 2024-04-25 21:47:38