The Maths Behind ‘Connect 4’

In a recent task assigned by Richard we were asked to explore the fundamental mathematics of a game. I have decided to investigate the mathematics involved in the seemingly simple game of ‘Connect 4’.

Connect 4 is a game with relatively simple rules (Victor Allis, 1988):

  1. Each player in his turn drops one of his checkers down any of the slots in the top of the grid.
  2. The play alternates until one of the players gets four checkers of his colour in a row. The four in a row can be horizontal, vertical, or diagonal.(See examples).
  3. The first player to get four in a row wins.
  4. If the board is filled with pieces and neither player has 4 in a row, then the game is a draw.

There is no set rule which states who takes the first turn, this is ultimately left to the players to decide. This decision may be crucial in deciding who wins the game…

screen-shot-2016-11-27-at-22-22-42

There are several different ways in which this game can be approached. By creating a simple rule player 1 (black) can ensure they win or draw every game. The rule is: Suppose n is even. Group the columns in pairs, giving pairs of columns 1 & 2, 3 & 4, …, (n-1) & n. Each time White plays in one column of a pair of columns, Black plays in the other column of the pair. For n is odd, groups are made in the same way, leaving the n-th column as a single column. The same rules apply to this position. Only if White plays in the n-th column, Black plays in that column, too.

Fundamental mathematics can be found in Connect 4 as the principles of probability and prescription are apparent. A player must attempt to predict where their opponent will place their next move. They must estimate the probability of their opponent predicting their next move and try to prevent them from making a move which will trap them and make them lose.

In relation to Liping Ma (2010) a player must have multiple perspectives when playing connect 4. This means that a person must be able to see the game in various ways and must be able to approach it in multiple ways. They must be aware that their opponent may have various moves available and they must be able to prevent any moves which will result in them losing. A person must also be able to take into consideration not just their opponents next move, but the next few moves they could make in order to guarantee a win. This could be done by recognising patterns they make.

When I played this game when I was younger I would try my best to place my counters in such a way that I create multiple opportunities for winning. For example create two lines of three meaning my opponent can only block one of my potential wins and leaving me with a guaranteed win. I would do this by considering possible patterns of play, trying to predict where my opponent would place counters to block mine but in some wscreen-shot-2016-11-27-at-22-22-01ays it could be argued that the game is somewhat down to luck. For example your opponent may get distracted and miss an opportunity to win or fail to notice your plan.

 

 

Reference:

Victor Allis (1988), A knowledge based approach to connect-four, Available at:

http://www.informatik.uni-trier.de/~fernau/DSL0607/Masterthesis-Viergewinnt.pdf  (Accessed on 27th November 2016)

Leave a Reply

Your email address will not be published. Required fields are marked *