|
-
Nov 12th, 2002, 04:59 PM
#1
Thread Starter
Addicted Member
Randomly choosing a control to work with...
I'm making a Tic-Tac-Toe game but I can't figure out how to let CPU to ramdomly choose a button to check its text to X.
Is this where control array comes? How would you code this?
EDIT:
I tried using blahblah or blahblah or ... ...
but it didn't work.
-
Nov 12th, 2002, 05:17 PM
#2
Sleep mode
-
Nov 12th, 2002, 05:26 PM
#3
Thread Starter
Addicted Member
I've read that before but that's only in VB6 code, isn't it?
-
Nov 12th, 2002, 05:29 PM
#4
Sleep mode
I guess so , but I sent you the link coz you were asking about the theory .
-
Nov 12th, 2002, 11:05 PM
#5
PowerPoster
I made a tic tac toe game where you play against the computer. Trust me when I say you don't want the computer to randomly place a mark anywhere it can. The game is so pointless. I don't have the code with me because I am away on business right now, but I will be home on Friday and can get it for you then. It is in VB6, but you can use the same principles for the AI.
Let me forwarn you though, I am not an AI master, and there is probably much easier ways to code it. I built three levels of AI into the tic tac toe game. The easy one will just randomly place a mark in an open slot. You can win 95% of the time. The next level will randomly place marks on the board, unless it can win, then it will always go for the win. You can beat this 60-80% of the time. The third level actually strategizes a little and can actually give you a run for your money (well, a kid anyway). I do still have one problem with the hard level because there is one pattern that you can do that will always win. I never found the problem because it was for kids, and didn't warrent anymore of my time.
If your interested in my code, I will get it to you when I get home. Just send me a email. I think I used a label control array to do the marks. Of course, in .Net though, they are not there.
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
|