I'm creating a TicTacToe Game, with classes, using C++ for school.
Part2 requires me to implement a single player mode (me vs the computer).
I have a matrix 3x3 and the function to randomly insert coordinates (CPU's move) always plays in the main diagonal (1,1;2,2;3,3).
If I put a breakpoint when I call the "random" method and debug step by step, it creates other coordinates, besides the main diagonal (which is good).
I don't understand why it only works if I'm debugging step by step.
Here's the random method:
void Ponto::aleatorio() {
srand(GetTickCount());
x = (rand() % 3)+1;
srand(GetTickCount());
y = (rand() % 3)+1;
}
Aucun commentaire:
Enregistrer un commentaire