I have a 2D array declared like this:
private Dots[][] dots = new Dots[8][8];
I'm making a game for educational purposes where the 2D array gets filled with dots, each having a color randomly selected out of a pool of four colors. The goal for the game is to connect the dots. When you connect dots of the same color, they get deleted and you get points for them. At the moment that's all working fine but I would like to add a new feature:
When you close the path, all dots contained in that path will be deleted aswell. (see image):
I'm thinking of an algorithm to find all dots contained in that path but I can't come up with one.
The path is stored in a LinkedList (probably irrelevant but I'm just saying it to be sure :) )
So to to summarize my question: I'm trying to come up with an algorithm to select the grey dots between the blue dots.
Note:
- Dots can be connected diagonally
- The path can be as long as the player wants
- The closed path can be of any shape
Edit 1: This is how the game looks:
Edit 2: This is what I mean with:
When you close the path, all dots contained in that path will be deleted aswell.



