Forked from zacharycarter/FindLowerElevation.java
Last active
December 24, 2016 02:14
-
-
Save tommyettinger/24e32ff63f1cb6b8f507f98846231802 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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