• 12
• 14
• 13
• 10
• 11
• entries
14
17
• views
5609

# Tic-Tac-Toe

172 views

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.

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.

There are no comments to display.