GAME DEV ยท OCT 2025

Nim & Tic Tac Toe

Two console games, Nim and Tic Tac Toe, with several difficulty levels, an optional AI player and a player versus player mode.

  • C#
  • Console
  • AI
  • Game Fundamentals
  • Algorithms
Nim & Tic Tac Toe screenshot

At a glance

ROLE
Solo developer
TEAM
Solo
CONTEXT
Final assignment of the Game Programming Fundamentals course

What I built

  • Nim with configurable piles and rules, input validation and a turn-based structure.
  • Tic Tac Toe on a 3 x 3 array with win and draw detection and an ASCII board.
  • Easy, medium and hard AI levels in both games.
  • Player versus player mode and replay until the player chooses to exit.
  • A colour-coded text system for the console output.

Technical decision

An AI that looks one move ahead

The medium AI tries every empty cell. It plays a cell, asks the same win check the game already uses whether that move ends the game, and undoes the move if it does not. It does this first for itself, then for the player to find a move it must block, and only plays at random when neither exists. Reusing the game's own win check means there is no second copy of the rules to keep in sync.

Program.cs
void GetMediumAIMove(char[,] board, int turn)
{
    //check if AI can win with the next move
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (!(board[i, j] == 'X' || board[i, j] == 'O'))
            {
                board[i, j] = 'O';
                if (CheckGameOver(turn, board, "checkIAsChoice"))
                {
                    return;
                }

                board[i, j] = ' ';
            }
        }
    }

    //check if the player can win with the next move 
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (!(board[i, j] == 'X' || board[i, j] == 'O'))
            {
                board[i, j] = 'X';
                if (CheckGameOver(turn, board, "checkIAsChoice"))
                {
                    board[i, j] = 'O';
                    return;
                }

                board[i, j] = ' ';
            }
        }
    }

    //choose a random movement
    GetEasyAIMove(board);
}
Snippet of one method. The whole game is in the public repo.โ†— VIEW ON GITHUB