CodingTrain / CodingTrain/Suggestion-Box
topic: random maze genorator
- 主要语言
- 没有语言数据
- 星标
- 570
- 派生
- 85
- PR 合并指标
- 30 天内没有已合并 PR
描述
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
}
}
```
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先查看链接的 CodePen 和伪代码,它们是仅有的实现参考。该 issue 未指定任何存储库文件、入口点、测试或验收标准,因此需要在开始工作前确定预期的实现范围和完成定义。
由索引模型根据 Issue 内容生成。
评估
- 领域
- game-dev
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 20/100