I was wondering if anyone can suggest a way I can make the computers moves of my tic tac toe game random? We have yet to cover stuff like this, so any help?
I was wondering if anyone can suggest a way I can make the computers moves of my tic tac toe game random? We have yet to cover stuff like this, so any help?
Check out rand(), or random() if you have Borland.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Yeah, but rand() won't really make the computer "smart"...yea i know as a programmer it's our job to make the computer smart...but I'm in no state of denial...I'm a newbie...
I am a newbie as well. And im using visual c++ 6.0. Its required for my class. So can anybody help?
What do you mean by 'smart' do you mean a leagal move or a good move.
maybe I can help you
I can do legal moves, but good moves is what i don't understand.
You mean you want AI?
Try something here. I don't know if this is any good.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
search the web for Minimax algorithm... one of the first things I created with the minimax function was a tic tac toe game, as a lot of people do. I am sure you will even find source code out there to look at.
Hi,
I think you should look for patterns, for example look for patterns where you could win with one move.
Then look for patterns where the opponent can win with one move then put the mark on it so he can't and so on.
You need to spend sometime on it, but it's wrothy...
After all the TicTacToe is not that difficult.