Counting the number of tiles in a path
I am making a multiplayer game with two teams. On each team there is a de-constructor(red) who has the ability to remove tiles and a builder(blue) who can place tiles. The time it takes for these actions are determined by the size of the chunk the player is currently standing on.
The chunks consist of tiles (as shown on the image below), and is expanded or decreased every time a player uses it's ability. Each tile has to know how many tiles it is connected to, i.e how big the chunk is.
I was thinking the count should take place every time the number of connections one tile has is changed. But how can i perform this count? is there an algorithm similar to DFS and BFS that does not need to know the graph size, or can you perform these without them knowing the graph size?
I remember this being part of the thesis of my friend who wrote a procedural dungeon generator. For these kinds of tasks he used "flood fill", an algorithm with which you should be able to get all the spaces and then all the islands. However you do this I recommend having your actual level a visual representation of an two dimensional array consisting of just the info about what is in each space (ground, floor, wall, whatever). Then you can simply use the algorithm on the array.
Your answer
Follow this Question
Related Questions
Object movement algorithm 0 Answers
Cannot access render pipelines - missing from Package manager (Unity 2019.1.14f1) 1 Answer
unity 3D URP Error 0 Answers