# Investigate the number of winning lines in the game Connect 4.

Extracts from this document...

Introduction

Year 11 mathematics coursework

– Connect 4 Investigation.

This is a winning line in the game Connect 4 on a 4x5 board. Winning lines can be horizontal, vertical or diagonal.

Investigate the number of winning lines in the game Connect 4.

The task asks for an investigation of the number of Connect 4 solutions in different sized grids. In Connect 4 the rules are that a winning line is a straight line of four connected counters in either a vertical, horizontal or diagonal line. To investigate this I must count the total number of possible winning solutions in a grid. The grid does not have too be any particular size however I will begin my investigation by using small grids, therefore the number of solutions will be smaller and easier to count. My results will be recorded in tables to make it easier to spot any patterns or trends. My aim is to establish formulae’s that will enable me too calculate the total number of winning lines for any given grid size. These are the steps I will take to complete the set task:

1. I will draw a range of differently sized grids and count the total amount of possible winning solutions each has on it, this will aid me in creating a formula.

2. After I have gathered all my results I will record them in tables.

3.

Middle

The addition of the two smaller formulas.

= h(w-3) + w(h-3)

= wh – 3w + wh – 3h

= 2wh – 3h – 3w : Formula

This larger formula tells me that when w = the width of the board and h= the height of the board, the number of horizontal and vertical winning lines can be calculated.

I will assure this by predicting the total number of winning lines on a 5x4 grid for a game of Connect 4, not including any possible winning diagonal lines.

### w=5

h=4

= 2wh – 3h – 3w

= 2(5x4) – (3x4) – (3x5)

= 40 – 12 – 15

=13 winning lines in total.

My prediction is that on a 5x4-sized grid, there are a total of 13 winning lines excluding the possible 4 diagonal winning lines. The diagram below justifies this being correct.

This grid is a 4 x 4 sized grid and it shows the solution for a winning diagonal line.

X | |||

X | |||

X | |||

x |

To make the equation slightly easier, I will only count one diagonal line on this board for now, then double it after.

I will begin by keeping the width at a constant total of 4 squares to begin with. The lowest value that w could be is 4, as if it were any lower there would be no possible diagonal winning lines.

This is a table showing the results I extracted from the grids on the previous page.

Height (h) | Width (w) | No. of winning lines | Solutions |

4 | 4 | 2 | 1 |

5 | 4 | 4 | 2 |

6 | 4 | 6 | 3 |

h | 4 | 2h-3 | h-3 |

Conclusion

4

4x as many

h

w

wx as many

If connect 5 were only possibly won by using only vertical lines the general formula for a (w) x (h)board would be:

Winning lines = w(h-4)

Once again, I added the two formulas for the horizontal and vertical winning lines together:

= h(w-4) + w(h-4)

= wh – 4w + wh – 4h

= 2wh – 4h – 4w

To find the number of winning lines (diagonal)

Height (h) | Width (w) | No. of winning lines | Solutions |

5 | 5 | 2 | 1 |

6 | 5 | 4 | 2 |

7 | 5 | 6 | 3 |

h | 5 | 2h-4 | h-4 |

This is a table of results after I increased the width of the board instead of keeping it constantly at 5.

Height (h) | Width (w) | No. of winning lines |

h | 6 | 2x as many |

h | 7 | 3x as many |

h | w | (w-4) (h-4) |

Therefore, to get the real number of diagonal winning solutions: 2 (w-4) (h-4)

Then I must add all the equations together to get the general formula for all winning lines in any direction on any size grid for a game of Connect 5:

2 (w-4) (h-4) + h(w-4) + w(h-4)

= 2wh – 8w – 8h +32 + wh – 4h +wh – 4w

= 4wh – 12w – 12h +32

To test the formula, I will do the same as I did before. I will predict the number of winning lines on a 5x4 board for a game of Connect 5 however this time I will include the possible diagonal winning lines, then use a diagram to prove my theory to be correct.

### w=6

h=5

= 4wh – 12w – 12h +32

= 4(6x5) – (12x6) – (12x5) + 32

= 120 – 72 – 60 + 32

= 20 winning lines in total.

My prediction is that on a 5x4 board, there are 20 winning lines. The diagram proves that this is correct.

Yousef Sharaan 11MG.

This student written piece of work is one of many that can be found in our GCSE Number Stairs, Grids and Sequences section.

## Found what you're looking for?

- Start learning 29% faster today
- 150,000+ documents available
- Just £6.99 a month