Created
December 24, 2016 01:51
-
-
Save zacharycarter/7b3811dcc3d6ff4b46cd28e4af27f2c1 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 = new GreasedRegion(heightData.data, Sand, heightData.data[currentLocation.x][currentLocation.y]); | |
GreasedRegion nonBlockedHeights = heights.andNot(riverBlockages); | |
int searchDistance = 40; | |
int cx = currentLocation.x, cy = currentLocation.y; | |
int x = 0, y = 0; | |
for(int rx = -searchDistance/2; rx < searchDistance/2; rx++) { | |
for(int ry = -searchDistance/2; ry < searchDistance/2; ry++) { | |
int dx = cx + rx, dy = cy + ry; | |
if(!contains(dx, dy)) continue; | |
if(nonBlockedHeights.contains(dx,dy)) return Coord.get(dx,dy); | |
y++; | |
} | |
y = 0; | |
x++; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment