The Connect Five engine is an example of artificial intelligence.
This page will show how the computer thinks. Some programming
experience might be needed to fully understand this page.
Ok, here we go....
The program has a memory buffer that stores the x's and o's
in the grid. The size of that buffer is 30x30 bytes, that is,
30 squares wide and 30 squares high.
The program also has another buffer that stores points.
Each square has a number of points. The square with the
highest amount of points is the square where the computer
places his o. The program has a special routine that
calculates the points of the squares.
Here are some examples of the point system:
Simple example of the point system.
The squares adjacent to the three-in-a-row gets 50
points each.
One side of the three-in-a-row is blocked.
The other square gets only 10 points.
This example demonstrates the benefits of using
the point system. Each square adjacent to a
three-in-a-row gets 50 points. But one square is
adjacent to two three-in-a-rows, and therefore, it
gets 50 + 50 = 100 points.
A full example of the point system. The square with the highest number
is where to put the o. Note that the square with
100 points is a winner.
To calculate the points of each square, the program looks for
several x's or o's in a row. A square adjacent to three x's in
a row might get 50 points, while a squre adjacent to four x's in
a row get 200 points. If the three x's has an o at the other
side, they are blocked, and the square would just get 10 points.
The program also has the ability to set it's agressivity. If the
player is in charge of the game, the computer plays defensive, but
if the computer is in charge, it plays agressive.
Generally, in connect five, it's better to play agressive than defensive.
To see who is in charge of the game, the program adds the total amount of points
for each side. The program multiplies his own points with the agressivity. So
that if the computer sees that it is in charge of the game, a three-in-a-row
might be worth 70 points instead of 50. In the same way, if he sees that he is
losing, his own three-in-a-rows will just be worth like 30 points. If you are in
a bad position in the game, it's more important to block the opponent than to make
own attacks.
Those are the basics of how this engine works. Any questions? Mail me.