Application Kata "Tic Tac Toe Bot"

Write a console program that allows a player to play [Tic Tac Toe] against a bot.

When the program starts, a new game begins, which looks like this:

 A B C
0 | |
 -+-+-
1 | |
 -+-+-
2 | |
Command:

Whether the human player or the bot is player 1, i.e. is allowed to make the first move, is determined randomly from game to game. If the bot is player 1, a new game already contains the bot's first move.

The human player moves by entering the coordinate of the square on which he wants to place his tile as a command [1], e.g. "A0" or "C2". The symbol of player 1's tile is "X", that of player 2 is "O".

After the human player has moved, the bot moves immediately. The updated display therefore always contains two new tiles. The human player is virtually always on the move.

If a player places his piece on a square that has already been filled, the board is displayed again without any changes. The player may try again.

The game board is redisplayed after each move. If player 1 moves to A0 and then player 2 moves to B1, the board looks like this:

 A B C
0X| |
 -+-+-
1 |O|
 -+-+-
2 | |
Command:

To start a new game, enter "new" instead of a playing field coordinate.

To exit the program, enter "end" as a command.

A game ends when no more moves are possible or a player has won. A corresponding message is displayed, e.g.
A B C
0X| |
 -+-+-
1X|O|O
 -+-+-
2X| |
*** The bot wins
Command:
Once a game has ended, only the "new" and "end" commands are interpreted.

Endnotes

[1] The commands should be understood without regard to upper/lower case.

en_USEnglish