Using simple and blind rules, what is the best tic-tac-toe player you can make?

I got on a kick trying to make tic-tac-toe computer players that lose, but don't just flop around on the floor... With that in mind, I've come up with a number of interesting abstractions, and a short puzzle for the interested reader. First we'll start by defining some properties of the board:

  • The Center is given the value 4
  • The Corners are given the value of 3
  • The Edges are given the value of 2
  • All values represent the number of winning pattens presented by a certain board location.

Next, we'll define some simple rules that I'll use in my tic-tac-toe player. The rules are processed in the order given. So each time it is the computer's turn to play they'll start at the top and go to the bottom.

  • Win - Place a winning piece if available.
  • Block - Place a blocking piece if need be.
  • Highest - Pick the highest open board position.

The above tic-tac-toe player is actually pretty good. As long as they play the above rules exactly, I believe there is only one way to beat them. That is both allowing them to place the first piece or the second piece. It isn't the smartest player, because it doesn't optmize it's own winning patterns, but it is a decent player. See if you can submit the game where it loses!

Published Friday, September 03, 2004 2:36 PM by Justin Rogers

Comments

Friday, September 03, 2004 6:30 PM by Jennie

# re: Using simple and blind rules, what is the best tic-tac-toe player you can make?

Justin, you know I can beat you at tic tac toe... :)
Saturday, September 04, 2004 1:39 AM by Justin Rogers

# re: Using simple and blind rules, what is the best tic-tac-toe player you can make?

Tic-Tac-Toe is a game of losing, not of winning. You can't beat someone at tic-tac-toe, they beat themselves. In fact the set of rules {Win, Block, Highest} will either win or tie any game where the AI is able to go first.

If the AI is the second player, then it will lose in two circumstances... You can fix one circumstance by swapping the rule Highest out for the rule Lowest after the first turn. There is still one game this doesn't fix.
Saturday, September 04, 2004 1:59 AM by Justin Rogers

# re: Using simple and blind rules, what is the best tic-tac-toe player you can make?

For a more complete opponent we can emphasize summation of the opponents moves and come up with some more rules.

Parity - Returns whether the sum of the opponents moves is even or odd treating 0 as returning a random parity (for first moves ;-)

ReverseParity - The reverse of the opponents pairty. Same random return for 0.

Highest(Parity) - Returns the highest rated board spot with a parity (with respect to the magic square) that matches the past in parity.

Win,
Block,
Highest(ReverseParity)

For the two failing games, selecting pieces based on the players move selections (summation with respect to the magic square) is enough to always win or tie...

Parity = Sum of Opponents Tiles % 2
ReverseParity = Sum Of Opponents Tiles + 1 % 2

If you don't want special treatment of parity then you can make the move dependent on the global turn.

Win,
Block,
{
gt=1: Highest(rand%2),
gt>1: Highest(ReverseParity)
}

gt stands for global turn or the turn with respect to all players. This is different from another variable lt, which stands for local turn.
Friday, June 27, 2008 10:55 PM by Andres

# re: Using simple and blind rules, what is the best tic-tac-toe player you can make?

Can you help me doing the codification of that rules in c++?

Sunday, July 13, 2008 2:43 PM by Lee

# re: Using simple and blind rules, what is the best tic-tac-toe player you can make?

Reply to Andres, June 27, 2008

I acquired an SR-52 programmable calculator in the mid 70s and decided to write a tic-tac-toe program for it. Since it had only 224 steps, I wrote a formula that played the game. At the URL given, you’ll find a “Pascal” like description on how to play the game based on a magic square. It is a different approach than the weighted one listed here, but has the (dis)advantage that it can not lose.

Sunday, July 13, 2008 5:35 PM by Lee

# re: Using simple and blind rules, what is the best tic-tac-toe player you can make?

The needed URL was stripped out of the message.

blueprintds.com/.../programming-tictactoe

Leave a Comment

(required) 
(required) 
(optional)
(required)