|Topic was automatically imported from the old Question2Answer platform.
Players place tiles (Walls) to enclose the K (Keep) tiles. Once a player does, the enclosed area turns the player’s color.
The code I have finds the total amount of Keeps, then for each Keep position, an instance of a Node2D with Area2D is created (a Seeker) and each Seeker gets a path to one Keep each.
Before the path sizes are changed, the size is checked if it is ZERO, if so, that Seeker is deleted and the Keep is added to the “enclosed” array, which fills in the area of that Keep. If the path is more than ZERO, it moves along the path until it reaches 0, then it confirms the Keep is not enclosed.
In the above example the first placement of walls encloses the Keep on the right. But it takes a second placement of Wall tiles (should be the first) to fill in the keep (which is another issue). Yet, the enclosed Keep is found to not have a path and the output is correct on that second placement. But on the third placement of a wall tile that does not enclose a Keep, somehow a path is found to it?
The walls are nodes change the tilemap upon placement. And the cells of the walls on the tilemap have no navigation. Plus I have called the tilemap to loop through all its child nodes and make sure the tilemap is updated before the paths for the Seekers are created. Yet, I can have all the Keep enclosed and they will still find a path to them, but only after they fail to find a way the first time.
I hope I explained the issue clearly.
Im happy to provide requested code!