Skip to content

Commit

Permalink
fix: rivers ending nowhere, holes in rivers
Browse files Browse the repository at this point in the history
sort starting points by height: highest riverstarts go first
  • Loading branch information
IR0NSIGHT committed Jan 18, 2024
1 parent fc7422c commit 208399f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
River,
} from "./pathing/river";
import { applyRiverLayers } from "./pathing/postprocessing";
import {getZ} from "./terrain";

const TILE_SIZE_BITS = 7;
const SHIFT_AMOUNT = 1 << TILE_SIZE_BITS; // Equivalent to 128
Expand Down Expand Up @@ -82,9 +83,13 @@ const main = () => {
const dims = mapDimensions();
log("map dimension: " + JSON.stringify(dims));

const startPoints: point[] = allAnnotatedPoints(getAllTiles())
const sortHighestFirst = (ps: point[]): point[] => {
ps.sort((a,b) => getZ(b) - getZ(a));
return ps;
}
const startPoints: point[] = sortHighestFirst(allAnnotatedPoints(getAllTiles()))

const passRandom = (p: point, chance: number): boolean => {
const passRandom = (p: point, chance: number): boolean => {
const seed = p.x * p.y + p.x;
//@ts-expect-error: provided by worldpainter context
return new java.util.Random(seed).nextFloat() < chance;
Expand Down

0 comments on commit 208399f

Please sign in to comment.