Info about Making a Game AI

Pages: 12
Some-one?
What is the need for recursion here?

The simplest, albeit not the the best way would surely be.

1
2
3
4
5
6
7
8
int x,y;
while(true) {
  x = rand()%3;
  y = rand()%3;

  if(Grid_pos[y][x] == ' ') break;
}
Grid_pos[y][x] = 'O';
If the AI just selects a random square, it's not going to be very competitive :p
If the AI just selects a random square, it's not going to be very competitive :p

After putting up the code to make a random move, the only way to defeat the computer will be to create a fork.
I decided to improve the computer player in steps. Firstly, I just made it a random blocker, and made it check for any row that can cause a victory or defeat.

What is the need for recursion here?

I find recursion the most straight forward method of doing something that has conditional checking, and then beginning again, with different values.
If the AI just selects a random square, it's not going to be very competitive :p


Competitive Tic. Tac. Toe.

=]

If you want that, make it an action game. Both parties going at the SAME. TIME. <(o.O)>
Last edited on
You missed a closing slash ;) And lol :P

I just meant that the AI should try to win.

And yes, playing in real time with rockets and air support would make it much more fun XD
Topic archived. No new replies allowed.
Pages: 12