Platform
Resources
Pricing
Sign in
Contact us
UnluckyNinja
Workspace
Fork
Public
Procedural Content Generation
By
UnluckyNinja
Edited
Oct 2, 2024
Procedural Content Generation
[PCG] Procedual map generation random stuff
[PCG] Maze
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// adapt this code for your application
viewof
distributionType
=
Inputs
.
select
(
[
"poisson"
,
"pseudoblue"
,
"hex"
,
"grid"
,
"random"
,
"normal"
]
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
delaunay
=
d3
.
Delaunay
.
from
(
[
...
rawPoints
,
...
samplePointsOnRectEdge
(
Math
.
min
(
width
,
500
)
+
12
,
Math
.
min
(
width
,
500
)
+
12
,
20
,
-
6
,
-
6
)
]
)
Insert cell
rawPoints
=
{
reroll
return
spawnPoints
(
{
type
:
distributionType
,
rect
:
{
x
:
0
,
y
:
0
,
width
:
Math
.
min
(
width
,
500
)
,
height
:
Math
.
min
(
width
,
500
)
}
,
n
:
2000
,
}
)
}
Insert cell
function
spawnPoints
(
options
=
{
}
)
{
const
{
type
,
rect
,
n
}
=
{
type
:
'poisson'
,
rect
:
{
x
:
0
,
y
:
0
,
width
:
1
,
height
:
1
}
,
n
:
100
,
...
options
,
}
// may change to seedable in the future.
return
[
...
pick2d
(
rect
.
width
,
rect
.
height
,
n
,
type
)
]
.
map
(
it
=>
[
it
[
0
]
+
rect
.
x
,
it
[
1
]
+
rect
.
y
]
)
}
Insert cell
spawnPoints
(
{
type
:
'poisson'
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
voronoi
=
delaunay
.
voronoi
(
[
-
6
,
-
6
,
Math
.
min
(
width
,
500
)
+
6
,
Math
.
min
(
width
,
500
)
+
6
]
)
Insert cell
Insert cell
noiseGenerator
=
simplex
.
createNoise2D
(
)
Insert cell
simplex
=
import
(
'https://unpkg.com/simplex-noise@4.0.1/dist/esm/simplex-noise.js?module'
)
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
scale
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
offsetX
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
offsetY
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
reroll
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
distributionType
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
delaunay
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rawPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
spawnPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
delaunayCentroids
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
triangleHeights
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
samplePointsOnRectEdge
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mergeSegments
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
voronoi
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
noiseGenerator
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
simplex
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML