0000008767800000000000000000
0000087656780000000000000000
0000876545678000000000000000
0008765434567800000000000000
0087654323----00000000000000
087654321| |0000000000000
87654321x|____|M000000000000
0876543212345678000000000000
0087654323456780000000000000
0008765434567800000000000000
0000876545678000000000000000
See, the x is the player, and the M is the mob. it expands recursively from the player until it finds the mob.
Then
void fill(x,y,int)
{
if(not block and not out of bounds)
{
grid[x][y]=int;
fill(x,y+1,int+1);
fill(x,y-1,int+1);
fill(x+1,y,int+1);
fill(x-1,y,int+1,int+1);
}
}