Tic-Tac-Toe Game Playing using Magic Square — Program 2 in AI

Helenjoy
4 min readJul 31, 2023

--

Magic Square

Here, we assign board positions to vector elements.

The Sum of all rows, columns, and diagonals must be 15.

Algorithm — Tic-Tac-Toe Game Playing using Magic Square — Program 2 in AI

The first machine uses a smart strategy to try and win the game.

It checks if adding the numbers on two squares equals 15. If this difference is not a positive number or if it is greater than 9, it means the two squares are not in a straight line, so it ignores them as potential winning moves.

Alternatively, the machine also looks at its opponent’s moves to block any chances of the opponent winning.

The main goal of the machine is to win as many games as possible.

Since no player can control more than four squares at a time, the machine examines far fewer squares using this method compared to a simpler approach like Program 2.

This example highlights how the way we represent information can greatly impact the efficiency of a problem-solving program. Choosing a clever representation can make the program work much better and more effectively.

Comments on Tic-Tac-Toe Game Playing using Magic Square — Program 2 in AI

This comparison sparks a thought-provoking inquiry into the relationship between human and computer problem-solving approaches.

The question of why people find the row-scan approach easier while the number-counting approach is more efficient for computers remains partly unanswered, as our understanding of human cognitive processes is still incomplete.

One significant aspect contributing to this difference is that humans possess parallel processing capabilities, allowing them to examine multiple parts of the board simultaneously. In contrast, conventional computers are limited to sequential processing, examining squares one at a time, which can affect their efficiency.

Exploring how humans solve problems can offer valuable insights into refining computer problem-solving techniques. Sometimes, human problem-solving methods shed light on optimal approaches for computers, while in other cases, the vast hardware differences between humans and machines necessitate unique strategies.

As we delve deeper into the realms of problem-solving for both humans and machines, our knowledge will likely advance, enabling us to determine whether identical representations and algorithms are ideal for both domains. This evolving understanding promises to shape the future of AI, enhancing its abilities and bridging the gap between human and artificial intelligence.

Example:

Now, the computer will check its possibility of winning the game.

First, calculate the difference between the 15 and the sum of two positions.

Diff = 15 — (5+4) = 6

6 is not empty, hence Computer can’t win the game.

Now, the computer checks the possibility of opponents winning the match. If the opponent is winning black it.

Diff = 15 — (8+6) = 1

1 is empty, hence the human can win the game.

Hence Computer Blocks it.

Computer — go to 1

Now, it’s Player Human Turn,

Now, the computer will check its possibility of winning the game.

Diff = 15 — (5+4) = 6

6 is not empty, hence Computer can’t win the game.

Diff = 15 — (1+4) = 10

10 is greater than 9, hence Computer can’t win the game.

Diff = 15 — (1+5) = 9

9 is empty, hence Computer can win the game. Computer — go to 9

--

--

Helenjoy

Research aspirant in deep learning based video compression