使用随机深度优先搜索算法生成带房间的多层迷宫
使用随机深度优先搜索算法生成带房间的多层迷宫Randomized depth-first searchRecursive implementation
1。Choose the initial cell, mark it as visited and push it to the stack
2。While the stack is not empty
1。Pop a cell from the stack and make it a current cell
2。If the current cell has any neighbours which have not been visited
1。Push the current cell to the stack
2。Choose one of the unvisited neighbours
3。Remove the wall between the current cell and the chosen cell
4。Mark the chosen cell as visited and pu ...
使wilson算法生成多层迷宫
多层迷宫生成We begin the algorithm by initializing the maze with one cell chosen arbitrarily.Then we start at a new cell chosen arbitrarily, and perform a random walk until we reach a cell already in the maze—however,if at any point the random walk reaches its own path, forming a loop,we erase the loop from the path before proceeding.When the path reaches the maze, we add it to the maze.Then we perform another loop-erased random walk from another arbitrary starting cell,repeating until all cells have ...
生成多层迷宫-公共源代码地址
多层迷宫生成的公共源代码maze_def.py链接地址maze_def.py
maze.py链接地址maze.py
draw_maze.py链接地址draw_maze.py
多层迷宫生成中的draw_maze.py
多层迷宫生成中的draw_maze.pydraw_maze.py
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154#!/usr/bin/python3.7# -*- coding: utf-8 -*-# create by 火苗999℃import pygame from maze import *title = '火苗999℃ ...
多层迷宫生成中的maze.py
多层迷宫生成中的maze.pymaze.py
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 ...
多层迷宫生成中的maze_def.py
多层迷宫生成中的maze_def.pymaze_def.py
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061#!/usr/bin/python3# -*- coding: utf-8 -*-# create by 火苗999℃# 多层迷宫 #标记 # 墙NOWALL = 0x0e # 无墙WALL = 0x01 # 有墙WALL_NO_VISIT = 0x01 # 没访问过的墙WALL_VISIT = 0x03 # 访问过的墙STEEL = 0X05 # 不能打通的墙# 格子CELL = 0x10 # 单元格CELL_NO_VISIT = 0x10 # 没访问过的格子CELL_VISIT = 0x30 # 访问过的格子CELL_VISIT_FLAG = 0X20 # 访问过标记STAIRS_U = 0x40 # 楼梯上STAIRS_D = 0x80 # 楼梯下STAIRS_UD = 0xC0 # 楼梯上下CE ...
使Kruskal's算法生成多层迷宫
多层迷宫生成Randomized Kruskal’s algorithmThis algorithm is a randomized version of Kruskal’s algorithm.
1.Create a list of all walls, and create a set for each cell, each containing just that one cell.
2.For each wall, in some random order:
1.If the cells divided by this wall belong to distinct sets:
1.Remove the current wall.
2.Join the sets of the formerly divided cells.
随机的Kruskal算法这个算法是Kruskal算法的随机化版本。
1。创建所有墙壁的列表,并为每个单元格创建一个集合,每个单元格只包含一个单元格。
2。对于每一面墙,以一些随机的顺序:
1。如果由这个壁分隔的细胞属于不同的集合:
1。 ...
使Randomized Prim's算法生成多层迷宫
多层迷宫生成Randomized Prim’s algorithm
1.Start with a grid full of walls.
2.Pick a cell, mark it as part of the maze. Add the walls of the cell to the wall list.
3.While there are walls in the list:
1.Pick a random wall from the list. If only one of the two cells that the wall divides is visited, then:
1.Make the wall a passage and mark the unvisited cell as part of the maze.
2.Add the neighboring walls of the cell to the wall list.
2.Remove the wall from the list.
随机普里 ...
使Aldous-Broder算法生成多层迷宫
多层迷宫生成Aldous-Broder algorithmThe Aldous-Broder algorithm also produces uniform spanning trees.
1.Pick a random cell as the current cell and mark it as visited.2.While there are unvisited cells:
1.Pick a random neighbour.
2.If the chosen neighbour has not been visited:
1.Remove the wall between the current cell and the chosen neighbour.
2.Mark the chosen neighbour as visited.
3.Make the chosen neighbour the current cell.
Aldous-Broder算法Aldous-Broder算法也生成统一的生成树。
1。选择一个随机的单元格作为当前单元 ...
使用随机深度优先搜索算法生成多层迷宫2
使用随机深度优先搜索算法生成多层迷宫源码123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 ...