|
-
Apr 29th, 2005, 11:59 AM
#1
Thread Starter
New Member
!!!Please help me with my tic-tac-toe game!!!
Im new to the forums
Iv made a visual basic Tic-Tac-Toe game, initially i wanted just for it to be a 2 player human game.. But iv decided i want to be able to play against a AI computer player, it does not have to be smart but it has to have some form of intelligence..
Here is the zip file with all the neccasary vb project/form files..
http://www.caldicot-pc-helpdesk.co.uk/Tic.zip
Basically what i need help with, is i want some way of selecting a 1 player game, i then want to be able to code is so that when the player chooses a square, it will run through the array and find all the enabled cmdbuttons, randomise and select a random cmdbutton and place a 0 or a X depending on what the computer player is..
Any help would be great..
-
Apr 29th, 2005, 02:58 PM
#2
Fanatic Member
Re: !!!Please help me with my tic-tac-toe game!!!
-
Apr 30th, 2005, 06:17 AM
#3
Thread Starter
New Member
Re: !!!Please help me with my tic-tac-toe game!!!
Got anything abit simpler?
-
Apr 30th, 2005, 06:30 AM
#4
Not NoteMe
Re: !!!Please help me with my tic-tac-toe game!!!
His example may seem complex at first, but really the bit that conserns you is relativly straight foward.
What he's doing, in easy mode, is to randomly pic a position (by choosing a random number), then if it's already taken then choose another one... When he finds a free space, he goes there.
VB Code:
Do
'Randomize the numbers that Rnd() generates (only need to do this once)
Randomize
'Generate a random number from 0 to 8
RndNum = Int(Rnd() * 9) + 0
'If this space is free then exit this loop
Loop Until Picture1(RndNum).Picture = 0
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Apr 30th, 2005, 07:03 AM
#5
Thread Starter
New Member
Re: !!!Please help me with my tic-tac-toe game!!!
so how would i apply this to an array of 0-8 cmdbuttons (when the cmdbutton is clicked by player1, computer randomises and picks a cmdbutton, if it has a caption of X or 0 then move to the next one, if the caption of the cmdbutton = "" then place a mark)
-
Apr 30th, 2005, 09:56 AM
#6
Not NoteMe
Re: !!!Please help me with my tic-tac-toe game!!!
Something like this i guess:
VB Code:
Do
'Randomize the numbers that Rnd() generates (only need to do this once)
Randomize
'Generate a random number from 0 to 8
RndNum = Int(Rnd() * 9) + 0
'If this space is free then exit this loop
Loop Until cmdbuttons(RndNum).text = ""
cmdbuttons(RndNum).text = "X" 'assuming computer is Xs
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|