commit a500757ccb397340c1afb9bbedce72d9bf2f6e49
parent b22441d60e45dbf97bc42e6318f9cf3f33f32e54
Author: Petar Yotsev <petar@yotsev.xyz>
Date: Sat, 22 Aug 2020 16:45:40 +0100
Add some comments for clarification
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/main.cpp b/main.cpp
@@ -200,8 +200,10 @@ int main(int argc, char** argv)
start = vec2<int>((std::rand() % ((width - 1) / 2)) * 2 + 1,
(std::rand() % ((height - 1) / 2)) * 2 + 1);
node grid[width * height];
+ // flood fill the grid
GetGridMap(field, grid, width, height, start);
{
+ // get node that's furthest away from initial point
node* current = &grid[0];
for (int y = 1; y < height; y += 2) {
for (int x = 1; x < width; x += 2) {
@@ -211,9 +213,11 @@ int main(int argc, char** argv)
}
start = current->pos;
}
+ // flood fill the grid
GetGridMap(field, grid, width, height, start);
int longestPathLength;
{
+ // get node that's furthest away from initial point
node* current = &grid[0];
for (int y = 1; y < height; y += 2) {
for (int x = 1; x < width; x += 2) {
@@ -223,6 +227,7 @@ int main(int argc, char** argv)
}
std::vector<vec2<int>> path;
node* previous = current;
+ // get (longest) path length between them
do {
path.push_back(previous->pos);
previous = previous->parent;