mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
reset PRNG - make points generation deterministic
This commit is contained in:
parent
a9755dacc8
commit
6a6ba96c96
2 changed files with 3 additions and 1 deletions
1
main.js
1
main.js
|
|
@ -669,6 +669,7 @@ function generateSeed() {
|
||||||
// Place points to calculate Voronoi diagram
|
// Place points to calculate Voronoi diagram
|
||||||
function placePoints() {
|
function placePoints() {
|
||||||
TIME && console.time("placePoints");
|
TIME && console.time("placePoints");
|
||||||
|
Math.random = aleaPRNG(seed); // reset PRNG
|
||||||
|
|
||||||
const cellsDesired = +pointsInput.dataset.cells;
|
const cellsDesired = +pointsInput.dataset.cells;
|
||||||
const spacing = (grid.spacing = rn(Math.sqrt((graphWidth * graphHeight) / cellsDesired), 2)); // spacing between points before jirrering
|
const spacing = (grid.spacing = rn(Math.sqrt((graphWidth * graphHeight) / cellsDesired), 2)); // spacing between points before jirrering
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ function getBoundaryPoints(width, height, spacing) {
|
||||||
function getJitteredGrid(width, height, spacing) {
|
function getJitteredGrid(width, height, spacing) {
|
||||||
const radius = spacing / 2; // square radius
|
const radius = spacing / 2; // square radius
|
||||||
const jittering = radius * 0.9; // max deviation
|
const jittering = radius * 0.9; // max deviation
|
||||||
const jitter = () => Math.random() * 2 * jittering - jittering;
|
const doubleJittering = jittering * 2;
|
||||||
|
const jitter = () => Math.random() * doubleJittering - jittering;
|
||||||
|
|
||||||
let points = [];
|
let points = [];
|
||||||
for (let y = radius; y < height; y += spacing) {
|
for (let y = radius; y < height; y += spacing) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue