original SLEUTHv3.0beta version spr_road_walk( ):

while (!end_of_road)
{
    end_of_road = TRUE;
    util_get_next_neighbor (i, j, &i_nghbr, &j_nghbr, RANDOM_INT (8));
    for (k = 0; k < 8; k++)
    {
         if (IMAGE_PT (i_nghbr, j_nghbr))
         {
             if (roads[OFFSET (i_nghbr, j_nghbr)])
             {
                end_of_road = FALSE;
                 run++;
                 i = i_nghbr;
                 j = j_nghbr;
                 break;
             }
         }
         util_get_next_neighbor (i, j, &i_nghbr, &j_nghbr, -1);
    }
     run_value = (int) (roads[OFFSET (i, j)] / MAX_ROAD_VALUE *
                 diffusion_coefficient);
    if (run > run_value)
    {
         end_of_road = TRUE;
         spread = TRUE;
         (*i_road_end) = i;
         (*j_road_end) = j;
     }
}

  FUNC_END;

  return spread;

 

*******************************************************************************************************************

new 3.0_patch_01 spr_road_walk( ):

while (!end_of_road)

  {

    end_of_road = TRUE;

    util_get_next_neighbor (i, j, &i_nghbr, &j_nghbr, RANDOM_INT (8));

    for (k = 0; k < 8; k++)

    {

      if (IMAGE_PT (i_nghbr, j_nghbr))

      {

        if (roads[OFFSET (i_nghbr, j_nghbr)])

        {

          end_of_road = FALSE;

          run++;

          i = i_nghbr;

          j = j_nghbr;

          break;

        }

      }

      util_get_next_neighbor (i, j, &i_nghbr, &j_nghbr, -1);

    }

    run_value = diffusion_coefficient;

    if (run > run_value)

    {

      end_of_road = TRUE;

      if (RANDOM_INT(100) <= (int) roads[OFFSET (i, j)])

      {

        spread = TRUE;

      }

      (*i_road_end) = i;

      (*j_road_end) = j;

    }

  }

  FUNC_END;

  return spread;

}