Tic-Tac-Toe
1,393
0
Advertisement
Source + installer (needs .NET Framework 2.0).
AI is moderately stupid, it will go for an obvious win or block yours but that's about it.
Summary of victory checking, since someone was asking about it:
Nothing fancy, just brute force.
Yeah, I was bored. Yeah, I'll get back to the asteroids thing.
AI is moderately stupid, it will go for an obvious win or block yours but that's about it.
Summary of victory checking, since someone was asking about it:
For each player 'p':bool won = false;for (int i = 0; i < 3; i++){ // Column if (gameBoard == p && gameBoard[i + 3] == p && gameBoard[i + 6] == p) won = true; // Row if (gameBoard[i * 3] == p && gameBoard[i * 3 + 1] == p && gameBoard[i * 3 + 2] == p) won = true;}// Diagonalif (gameBoard[4] == p) // center{ if (gameBoard[0] == p && gameBoard[8] == p) won = true; if (gameBoard[2] == p && gameBoard[6] == p) won = true;}Nothing fancy, just brute force.
Yeah, I was bored. Yeah, I'll get back to the asteroids thing.
Advertisement
Advertisement
Advertisement
Discussion