Skip to content

Instantly share code, notes, and snippets.

@tommyettinger
Forked from zacharycarter/FindLowerElevation.java
Last active December 24, 2016 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommyettinger/24e32ff63f1cb6b8f507f98846231802 to your computer and use it in GitHub Desktop.
Save tommyettinger/24e32ff63f1cb6b8f507f98846231802 to your computer and use it in GitHub Desktop.
private Coord findLowerElevation(Coord currentLocation, GreasedRegion riverBlockages,
GreasedRegion heights, GreasedRegion reuse, GreasedRegion temp) {
heights.refill(heightData.data, Sand, heightData.data[currentLocation.x][currentLocation.y])
.andNot(riverBlockages);
reuse.clear().insert(currentLocation);
temp.remake(reuse).fringe();
int searchDistance = 40;
for(int d = 1; d < searchDistance; d++)
{
if(temp.intersects(heights))
{
return temp.singleRandom(CommonRNG.getRng());
}
temp.remake(reuse.expand()).fringe();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment