Best way to detect if a line of 4 of the same elements is formed?

Hello!

I’m making a version of Connect-4. You need to have 4 tiles that are in a line. This line can be diagonal, horizontal or vertical.
I’ve represented this as a 6x7 (6 rows, 7 columns) 2d array.
For checking if a line has been made horizontally or vertically, it’s relatively straightforward. You simply add a column or row count that contains the number of tiles on that line.
However, for the diagonal count, it gets much harder. Does anyone know a way to do this?

One method that I thought of was giving every tile an “adjacent tile” count, but there are a few issues with this:

  • you need a separate table to contain all of that data :confused:
  • i don’t really know what to do with that information anyway, lol.