- Author: WaltsonZh
- Email: waltson2003@gmail.com
This is a simple Tic-Tac-Toe web game implemented using vanilla JavaScript. The game board is represented using HTML table cells, and the player symbols are drawn on canvas elements within each cell.
- Visit my site to play.
- Choose your move of "X" or "O" ("X" always starts first, choose "O" to let AI go first).
The AI opponent uses a simple algorithm to make its moves. It follows a set of rules to prioritize certain moves based on the current game state:
- If it's the AI's first move, it will place its symbol in the center cell if it's available. Otherwise, it will place it in any corner cell.
- If it's the AI's second move, it will block the player if the player has a winning move or place its symbol in an optimal position to create two in a row.
- On subsequent moves, the AI will try to win the game if it has two in a row or block the player if the player has two in a row.
- If there are no immediate winning moves or blocking moves, the AI will place its symbol in an empty cell based on a predetermined priority order.
- Comments and README.md generated by ChatGPT.
- AI algorithm referenced from google Tic-Tac-Toe game.