To find the number of winning lines (horizontal only).
Therefore on a 1 x (w) board, the number of winning lines = w - 3
I then decided to alter the height of the grid, instead of constantly keeping it at 1 square I decide to increase it by 1 square on each separate grid. However I still only drew on the winning horizontal lines.
These are my results after I had extended the height of the grid by 1 square instead of keeping it at a constant 1 square.
If Connect 4 were only possibly won by using horizontal lines, the general formula for a (w) x (h) board would be:
Winning lines = h (w - 3)
To work out the total number of winning vertical lines, I used the same method as I had for the number horizontal winning lines.
I again used small sized grids as shown below, however this time the width stayed as 1 square as the height measurement was increased.
This table shows the number of vertical winning lines recorded from the grids on the previous page.
Therefore on a 1 x (h) board the total number of winning lines=h - 3.
I then decided to alter the width of the grid, instead of constantly keeping it at 1 square I decide to increase it by 1 square on each separate grid. However I still only drew on the winning vertical lines.
The table shows the results I tabulated from the grids I decided to alter the size of on the previous page.
If Connect 4 were only possibly won by using only vertical lines, the general formula for a (w) x (h) board would be:
Winning lines = w (h - 3)
Now that I have established two separate formulas that tell me the total number of vertical and horizontal winning lines, I will add them together therefore giving me a larger more specific formula that tells me the number of both horizontal and vertical winning lines on a (w) x (h) grid.
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.
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.
These would be the results I would gather if I were to increase the width of the board.
Therefore, to get the real number of solutions: 2 (w-3) (h-3)
If I add together the formula for the horizontal/vertical lines and the new one I have achieved for diagonals (above in bold) I should achieve a formula that will tell me the number of winning lines in all possible 3 directions on any sized board for Connect 4.
2 (w-3) (h-3) + h(w-3) + w(h-3)
= 2wh – 6w – 6h +18 + wh – 3h +wh – 3w
= 4wh – 9w – 9h +18 (Formula for winning lines on any sized board)
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 4 however this time I will include the possible diagonal winning lines, then use a diagram to prove my theory to be correct.
w=5
h=4
= 4wh – 9w – 9h +18
= 4(5x4) – (9x5) – (9x4) + 18
= 80 – 45 – 36 +18
= 17 winning lines in total.
My prediction is that on a 5x4 board, there are 17 winning lines. The diagram proves that this is correct.
This tells me the number of winning lines on any sized board for Connect 4. I will now expand my investigation by repeating my Connect 4 investigation for Connect 5.
Connect 5
I began by drawing small boards that Connect 5 would be played on and drawing on the possible winning lines.
To find the number of winning lines (horizontal only).
Therefore on a 1 x (w) grid, the number of winning lines = w - 4
I extended the height of the board by 1 square on each separate grid however I still only drew on horizontal winning lines.
These are my results after I had extended the height of the grid by 1 square on each grid instead of keeping it at a constant 1 square.
If Connect 5 were only possibly won by using horizontal lines, the general formula for a (w) x (h) board would be:
Winning lines = h (w - 4)
To work out the total number of winning vertical lines, I used the same method as I had for the number horizontal winning lines.
I again used small sized grids as shown below, however this time the width stayed as 1 square as the height measurement was increased.
This table shows the number of vertical winning lines recorded from the grids on the previous page.
Therefore on a 1 x (h) board, the number of winning lines = h - 4.
I then decided to alter the width of the grid, instead of constantly keeping it at 1 square I decide to increase it by 1 square on each separate grid. However I still only drew on the winning vertical lines.
The table shows the results I tabulated from the grids I decide to alter the size of on the previous page.
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)
This is a table of results after I increased the width of the board instead of keeping it constantly at 5.
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.