Anonymous user
Maze generation: Difference between revisions
→{{header|PureBasic}}: changed some code constants
(→{{header|D}}: Not a dept first search) |
(→{{header|PureBasic}}: changed some code constants) |
||
Line 707:
=={{header|PureBasic}}==
<lang PureBasic>Enumeration
;indexes for types of offsets from maze coordinates (x,y)
#visited ;used to index visited(x,y) in a given direction from current maze cell
#maze ;used to index maze() in a given direction from current maze cell
#wall ;used to index walls in maze() in a given direction from current maze cell
#numOffsets = #wall
;direction indexes
#dir_ID = 0 ;identity value, produces no changes▼
#dir_N = 0▼
#firstDir
#dir_E
#dir_S
#dir_W
#numDirs = #dir_W
▲ #dir_ID ;identity value, produces no changes
EndEnumeration
DataSection
;maze(x,y) offsets for visited, maze, & walls for each direction
Data.i 1, 1, 0, 0, 0, 0 ;ID
Data.i 1, 0, 0, -1, 0, 0 ;N
Data.i 2, 1, 1, 0, 1, 0 ;E
Data.i 1, 2, 0, 1, 0, 1 ;S
Data.i 0, 1, -1, 0, 0, 0 ;W
Data.i
EndDataSection
;setup reference values indexed by direction from current map cell
Global Dim offset.POINT(
Define i, j
For i =
For j = 0 To
Read.i offset(j, i)\x: Read.i offset(j, i)\y
Next
Next
Global Dim wallvalue(#
For i =
Procedure displayMaze(Array maze(2))
Line 776 ⟶ 778:
NewList stack.POINT()
Dim unvisited(#
Repeat
cellCount = 0
For i = #
If Not visited(x + offset(#visited, i)\x, y + offset(#visited, i)\y)
unvisited(cellCount) = i: cellCount + 1
Line 814 ⟶ 816:
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()
EndIf</lang>
Sample output:
<pre>Started generation at 9 x 3
|