Line 1:
Line 1:
+
=== Flood Fill Algorithm ==
+
I have tried changing hte algorithm as the one previously used doesnt take walls into account.
+
I am now trying different algorithms including a modified flood(/seed/bucket) fill.
+
+
[CODE]
+
void bucket_fill(int x, int y, int value)
+
{
+
if (grid[x, y] == 0 || (grid[x,y]-value) > 0)
+
{
+
grid[x, y] = value;
+
if (x < map_size-1)
+
bucket_fill(x + 1, y, value+1);
+
if(x>0)
+
bucket_fill(x - 1, y, value+1);
+
if (y < map_size-1)
+
bucket_fill(x, y+1, value+1);
+
if(y>0)
+
bucket_fill(x, y-1, value+1);
+
+
}
+
+
}
+
[/CODE]
+
This is gives the right result when used on a small map, but larger maps give stack overflows. I will try and use a queue instead, as this should be smaller.
+
==Algorithm==
==Algorithm==
For those wondering the algorithm I am using to get the gradient can be defined as such...
For those wondering the algorithm I am using to get the gradient can be defined as such...