The Will-Never-Lose-TicTacToe Strategy

Applying the following rules in the given order. If any rule is selected then the subsequent rules are ignored. Note: m: computer's symbol, n: user's symbol

Rule#1: See if the computer can win.
Rule#2: Block the users winning slot.
Rule#3: Now here you can play some tricks.

a) If n is the only symbol and and not in the
center then occupy the center.

b) If the board is blank put m on any corner.
Subsequently (i.e. in next step), put m in any
position such that number of winning positions
for m is 0.

Rule#4: Find a list of all those positions where placing
an n would result in two winning positions for
the user. Put m in a position which makes a winning
position not belonging to this list.

Rule#5: Find a position where placing an m
would result in two winning positions.

Rule#6: Put a m such that it results in one
winning position, if possible in the center.

Rule#7: Put a m in any blank place.
Rule#8: return ERROR, this should ideally not execute

This strategy has been used by the TicTacToe class and ensures that the computer will never lose!

Strategy designed by Bhurvi and me.

Hosted by www.Geocities.ws

1