If steepness is high, the algorithm aborts after six attempts. This makes sense, but it would be even nicer if it attempted to find a hex in distance 2!

# pick some random neighbors based on steepness (allow fractions) my $n = int($steepness); $n++ if rand() < $steepness - $n; for (1 .. $n) { # try to find an empty neighbor; abort after six attempts for (1 .. 6) { my $i = int(rand(6)); my ($x, $y) = neighbor($coordinates, $i); next unless legal($x, $y); my $other = coordinates($x, $y); next if $altitude->{$other}; # if we found an empty neighbor, set its altitude $altitude->{$other} = $current_altitude; push(@next, $other); last; } }

Tags: Issue Hex Mapping Closed

## Comments