CodingTrain / CodingTrain/Suggestion-Box

topic: random maze genorator

Abierto
#970 1 comentario 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Sin datos de lenguaje
Estrellas
570
Forks
85
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I found a way to generate a random maze from a point. I have not found any article about it but i tried programing it and can write some pseudocode.

The main idea:

Draw a point.
Draw another point X far from the first one and draw a line to it.
Pick one of the points and draw another point X far from it and draw a line to that point.
and so on but you only have to follow one rule:

**never let two points go closer than X far from each other**

it is not as easy as it sounds because of lag but i think a quadtree would work.

[https://codepen.io/ProGramer31415/pen/BxPWXx](url)

Here is some pseudocode, I am not good at writing pseudocode:
```
class node {
main(x, y) {
keep position of node
create an array of nodes created from this node, starts empty
}
addChild(x, y) {
create new child at x, y
add child to array of children
}
draw() {
draw line from node to all children
}
}

class maze {
main(segment-length) {
create array / quadtree of nodes and add one node to it
create variable with length of each segment
}

update() {
pick a random node
pick a random position segment-length far from the node
check if the random position is legal with moveLegal
if its legal {
add a new kid to the random node with the random position
add the kid to the array of nodes
}
}

moveLegal(x, y) {
check if the length to the closest node in the mazes array of nodes is more than segment-length.
if so return true
else return false
}
}
```

screenshot 2018-05-14 16 23 53

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.