I designed simple AI for 3x3 Tic Tac Toe game. However I didn't want to do neither complete search, nor MinMax. Instead i thought of a heuristic that would evaluate values for all of 9 fields, and then AI would choose the field with highest value. The problem is, I have absolutely no idea how to determine, whether it is a perfect (unbeatable) algorithm.
And here are the details: Every Field has several WinPaths on the grid. Middle one has 4 (horizontal, vertical and two diagonals), corners have 3 each (horizontal, diagonal and one vertical), sides have only 2 each (horizontal and vertical). Value of each Field equals sum of its WinPaths values. And WinPath value depends on its contents:
- Empty:
[ | | ]
- 1 point - One symbol:
[X| | ]
- 10 points// can be any symbol in any place
- Two different symbols:
[X|O| ]
- 0 points// they can be arranged in any possible way
- Two identical opponents symbols:
[X|X| ]
- 100 points// arranged in any of three ways
- Two identical "my" symbols:
[O|O| ]
- 1000 points// arranged in any of three ways
This way for example beginning situation has values as below:
3 | 2 | 3
---+---+---
2 | 4 | 2
---+---+---
3 | 2 | 3
However a later one can be like this (X is moving now):
X | 10| O
---+---+---
O | O |110
---+---+---
X | 20| 20
So is there any reliable way to find out whether is this a perfect algorithm, or does it have any disadvantages?
PS. I was trying (from the perspective of player) to create a fork situation so I could beat this AI, but I have failed.