Private Sub OutputRectangle(XMax As Double, XOffset As Double, YMax As Double, Rectangle() As VertexRec, PixelsPerX As Double, PixelsPerZ As Double, CosTilt As Double, SinTilt As Double, RelDistOfUserFromScreen As Double, FaceColor As Integer)
Private Sub OutputLeftRight(XMax As Double, XOffset As Double, YMax As Double, Rectangle() As VertexRec, PixelsPerX As Double, PixelsPerZ As Double, CosTilt As Double, SinTilt As Double, RelDistOfUserFromScreen As Double)
Private Sub DrawLine(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, XMax As Double, XOffset As Double, YMax As Double, CosTilt As Double, SinTilt As Double, PixelsPerX As Double, PixelsPerZ As Double, RelDistOfUserFromScreen As Double)
Private Sub Hash(Counter0 As Byte, Counter1 As Byte, Counter2 As Byte, Counter3 As Byte, Counter4 As Byte, Counter5 As Byte, Counter6 As Byte, Counter7 As Byte)
Dim Iteration As Byte
Dim Seed0 As Byte
Dim Seed1 As Byte
Dim Seed2 As Byte
Dim Seed3 As Byte
Dim Seed4 As Byte
Dim Seed5 As Byte
Dim Seed6 As Byte
Dim Seed7 As Byte
Dim SubstitutionIndex As Byte
Dim Tem0 As Byte
Dim Tem1 As Byte
Dim Tem2 As Byte
Seed0 = Counter0
Seed1 = Counter1
Seed2 = Counter2
Seed3 = Counter3
Seed4 = Counter4
Seed5 = Counter5
Seed6 = Counter6
Seed7 = Counter7
For Iteration = 1 To 8
SubstitutionIndex = 10 * Seed1 + Seed0
Tem0 = SubstitutionLow(SubstitutionIndex)
Tem1 = SubstitutionHigh(SubstitutionIndex)
SubstitutionIndex = 10 * Seed3 + Seed2
Seed0 = SubstitutionLow(SubstitutionIndex)
Tem2 = SubstitutionHigh(SubstitutionIndex)
SubstitutionIndex = 10 * Seed5 + Seed4
Seed2 = SubstitutionLow(SubstitutionIndex)
Seed1 = SubstitutionHigh(SubstitutionIndex)
SubstitutionIndex = 10 * Seed7 + Seed6
Seed5 = SubstitutionLow(SubstitutionIndex)
Seed7 = SubstitutionHigh(SubstitutionIndex)
Seed3 = Tem0
Seed6 = Tem1
Seed4 = Tem2
Next Iteration
Counter0 = Seed0
Counter1 = Seed1
Counter2 = Seed2
Counter3 = Seed3
Counter4 = Seed4
Counter5 = Seed5
Counter6 = Seed6
Counter7 = Seed7
End Sub
Private Sub Increment(Counter0 As Byte, Counter1 As Byte, Counter2 As Byte, Counter3 As Byte, Counter4 As Byte, Counter5 As Byte, Counter6 As Byte, Counter7 As Byte)
Dim tem As Byte
tem = Counter0 + 1
If tem <= 9 Then
Counter0 = tem
Else
Counter0 = 0
tem = Counter1 + 1
If tem <= 9 Then
Counter1 = tem
Else
Counter1 = 0
tem = Counter2 + 1
If tem <= 9 Then
Counter2 = tem
Else
Counter2 = 0
tem = Counter3 + 1
If tem <= 9 Then
Counter3 = tem
Else
Counter3 = 0
tem = Counter4 + 1
If tem <= 9 Then
Counter4 = tem
Else
Counter4 = 0
tem = Counter5 + 1
If tem <= 9 Then
Counter5 = tem
Else
Counter5 = 0
tem = Counter6 + 1
If tem <= 9 Then
Counter6 = tem
Else
Counter6 = 0
tem = Counter7 + 1
If tem <= 9 Then
Counter7 = tem
Else
Counter7 = 0
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub HexDisplaySolution(MaxY As Integer, Page() As Byte, XMax As Double, XOffset As Double, YMax As Double, CosTilt As Double, SinTilt As Double, PixelsPerX As Double, PixelsPerZ As Double, RelDistOfUserFromScreen As Double)
Private Sub HexDisplayUserMoves(MaxX As Integer, MaxY As Integer, Page() As Byte, XMax As Double, XOffset As Double, YMax As Double, CosTilt As Double, SinTilt As Double, PixelsPerX As Double, PixelsPerZ As Double, RelDistOfUserFromScreen As Double)
Private Sub HexSolveMaze(Stack() As StackRec, Page() As Byte, NumRoomsInSolution As Integer, Adjacency As Integer, MaxX As Integer, MaxY As Integer)
Dim DeltaIndex As Byte
Dim PassageFound As Integer
Dim StackHead As Integer
Dim X As Integer
Dim XNext As Integer
Dim Y As Integer
Dim YNext As Integer
NumRoomsInSolution = 1
Adjacency = 0
X = 3
Y = 2
StackHead = -1
Page(Y, X) = 1
Do
DeltaIndex = 0
PassageFound = False
Do
Do While ((DeltaIndex < 6) And (Not PassageFound))
XNext = X + HexDeltaX(DeltaIndex, 0)
YNext = Y + HexDeltaY(DeltaIndex, 0)
If Page(YNext, XNext) = 2 Then
PassageFound = True
Else
DeltaIndex = DeltaIndex + 1
End If
Loop
If Not PassageFound Then
DeltaIndex = Stack(StackHead).Index1
Page(Y, X) = 2
X = X - HexDeltaX(DeltaIndex, 0)
Y = Y - HexDeltaY(DeltaIndex, 0)
Page(Y, X) = 2
X = X - HexDeltaX(DeltaIndex, 0)
Y = Y - HexDeltaY(DeltaIndex, 0)
StackHead = StackHead - 1
DeltaIndex = DeltaIndex + 1
End If
Loop While Not PassageFound
Page(YNext, XNext) = 1
XNext = XNext + HexDeltaX(DeltaIndex, 0)
YNext = YNext + HexDeltaY(DeltaIndex, 0)
If YNext <= MaxY Then
StackHead = StackHead + 1
Stack(StackHead).Index1 = DeltaIndex
Page(YNext, XNext) = 1
X = XNext
Y = YNext
End If
Loop While YNext < MaxY
X = MaxX - 3
Y = MaxY - 2
Adjacency = 0
Do While (StackHead >= 0)
For DeltaIndex = 0 To 5
XNext = X + HexDeltaX(DeltaIndex, 0)
YNext = Y + HexDeltaY(DeltaIndex, 0)
If Page(YNext, XNext) <> 1 Then
If Page(YNext, XNext) = 0 Then
XNext = XNext + HexDeltaX(DeltaIndex, 0)
YNext = YNext + HexDeltaY(DeltaIndex, 0)
If XNext < 0 Then
Adjacency = Adjacency + 1
Else
If XNext > MaxX Then
Adjacency = Adjacency + 1
Else
If YNext < 0 Then
Adjacency = Adjacency + 1
Else
If YNext > MaxY Then
Adjacency = Adjacency + 1
Else
If Page(YNext, XNext) = 1 Then
Adjacency = Adjacency + 1
End If
End If
End If
End If
End If
End If
End If
Next DeltaIndex
X = X - 2 * HexDeltaX(Stack(StackHead).Index1, 0)
Y = Y - 2 * HexDeltaY(Stack(StackHead).Index1, 0)
StackHead = StackHead - 1
NumRoomsInSolution = NumRoomsInSolution + 1
Loop
For DeltaIndex = 0 To 5
XNext = X + HexDeltaX(DeltaIndex, 0)
YNext = X + HexDeltaY(DeltaIndex, 0)
If Page(YNext, XNext) <> 2 Then
If Page(YNext, XNext) = 0 Then
XNext = XNext + HexDeltaX(DeltaIndex, 0)
YNext = YNext + HexDeltaY(DeltaIndex, 0)
If XNext < 0 Then
Adjacency = Adjacency + 1
Else
If XNext > MaxX Then
Adjacency = Adjacency + 1
Else
If YNext < 0 Then
Adjacency = Adjacency + 1
Else
If YNext > MaxY Then
Adjacency = Adjacency + 1
Else
If Page(YNext, XNext) = 1 Then
Adjacency = Adjacency + 1
End If
End If
End If
End If
End If
End If
End If
Next DeltaIndex
End Sub
Private Sub HexGenerateMaze(Page() As Byte, MaxX As Integer, MaxY As Integer, Stack() As StackRec, NumColumns As Integer, NumRows As Integer, Seed() As Byte)
Dim ColumnNum As Integer
Dim DeltaIndex1 As Integer
Dim DeltaIndex2 As Integer
Dim PassageFound As Integer
Dim RN(7) As Integer
Dim RNIndex1 As Integer
Dim RNIndex2 As Integer
Dim RowNum As Integer
Dim SearchComplete As Integer
Dim StackHead As Integer
Dim TemInt As Integer
Dim X As Integer
Dim XMod8 As Byte
Dim XNext As Integer
Dim Y As Integer
Dim YMod4 As Byte
Dim YNext As Integer
RN(0) = Seed(0) + 1
RN(1) = Seed(1) + 1
RN(2) = Seed(2) + 1
RN(3) = Seed(3) + 1
RN(4) = Seed(4) + 1
RN(5) = Seed(5) + 1
RN(6) = Seed(6) + 1
RN(7) = Seed(7) + 1
YMod4 = 1
For Y = 0 To MaxY
If YMod4 = 1 Then
XMod8 = 1
For X = 0 To MaxX
If (((XMod8 = 0) And (Y <> 0) And (Y <> MaxY)) Or (XMod8 = 3) Or (XMod8 = 4) Or (XMod8 = 5)) Then
Page(Y, X) = 0
Else
Page(Y, X) = 2
End If
XMod8 = XMod8 + 1
If XMod8 >= 8 Then XMod8 = 0
Next X
Else
If YMod4 = 0 Or YMod4 = 2 Then
XMod8 = 1
For X = 0 To MaxX
If (XMod8 = 2) Or (XMod8 = 6) Then
Page(Y, X) = 0
Else
Page(Y, X) = 2
End If
XMod8 = XMod8 + 1
If XMod8 >= 8 Then XMod8 = 0
Next X
Else
XMod8 = 1
For X = 0 To MaxX
If (XMod8 = 0) Or (XMod8 = 1) Or (XMod8 = 4) Or (XMod8 = 7) Then
Page(Y, X) = 0
Else
Page(Y, X) = 2
End If
XMod8 = XMod8 + 1
If XMod8 >= 8 Then XMod8 = 0
Next X
End If
End If
YMod4 = YMod4 + 1
If YMod4 >= 4 Then YMod4 = 0
Next Y
ColumnNum = RN(0)
RNIndex1 = 0
RNIndex2 = 1
Do While (RNIndex2 < 8)
TemInt = RN(RNIndex2)
RN(RNIndex1) = TemInt
ColumnNum = ColumnNum + TemInt
If ColumnNum >= 727 Then ColumnNum = ColumnNum - 727
RNIndex1 = RNIndex2
RNIndex2 = RNIndex2 + 1
Loop
RN(7) = ColumnNum
ColumnNum = ColumnNum Mod NumColumns
X = 4 * ColumnNum + 3
RowNum = RN(0)
RNIndex1 = 0
RNIndex2 = 1
Do While (RNIndex2 < 8)
TemInt = RN(RNIndex2)
RN(RNIndex1) = TemInt
RowNum = RowNum + TemInt
If RowNum >= 727 Then RowNum = RowNum - 727
RNIndex1 = RNIndex2
RNIndex2 = RNIndex2 + 1
Loop
RN(7) = RowNum
If ColumnNum Mod 2 Then
RowNum = RowNum Mod (NumRows - 1)
Y = 4 * RowNum + 4
Else
RowNum = RowNum Mod NumRows
Y = 4 * RowNum + 2
End If
Page(Y, X) = 2
StackHead = -1
Do
DeltaIndex1 = 0
Do
DeltaIndex2 = RN(0)
RNIndex1 = 0
RNIndex2 = 1
Do While (RNIndex2 < 8)
TemInt = RN(RNIndex2)
RN(RNIndex1) = TemInt
DeltaIndex2 = DeltaIndex2 + TemInt
If DeltaIndex2 >= 727 Then DeltaIndex2 = DeltaIndex2 - 727
RNIndex1 = RNIndex2
RNIndex2 = RNIndex2 + 1
Loop
RN(7) = DeltaIndex2
Loop While DeltaIndex2 >= 720
PassageFound = False
SearchComplete = False
Do While (Not SearchComplete)
Do While ((DeltaIndex1 < 6) And (Not PassageFound))
XNext = X + 2 * HexDeltaX(DeltaIndex1, DeltaIndex2)
If XNext <= 0 Then
DeltaIndex1 = DeltaIndex1 + 1
Else
If XNext > MaxX Then
DeltaIndex1 = DeltaIndex1 + 1
Else
YNext = Y + 2 * HexDeltaY(DeltaIndex1, DeltaIndex2)
If YNext <= 0 Then
DeltaIndex1 = DeltaIndex1 + 1
Else
If YNext > MaxY Then
DeltaIndex1 = DeltaIndex1 + 1
Else
If Page(YNext, XNext) = 0 Then
PassageFound = True
Else
DeltaIndex1 = DeltaIndex1 + 1
End If
End If
End If
End If
End If
Loop
If Not PassageFound Then
If StackHead >= 0 Then
DeltaIndex1 = Stack(StackHead).Index1
DeltaIndex2 = Stack(StackHead).Index2
X = X - 2 * HexDeltaX(DeltaIndex1, DeltaIndex2)
Y = Y - 2 * HexDeltaY(DeltaIndex1, DeltaIndex2)
StackHead = StackHead - 1
DeltaIndex1 = DeltaIndex1 + 1
End If
End If
If ((PassageFound) Or ((StackHead = -1) And (DeltaIndex1 >= 6))) Then
SearchComplete = True
Else
SearchComplete = False
End If
Loop
If PassageFound Then
StackHead = StackHead + 1
Stack(StackHead).Index1 = DeltaIndex1
Stack(StackHead).Index2 = DeltaIndex2
Page(YNext, XNext) = 2
Page((Y + YNext) \ 2, (X + XNext) \ 2) = 2
X = XNext
Y = YNext
End If
Loop While StackHead <> -1
Page(0, 3) = 1
Page(MaxY, MaxX - 3) = 2
End Sub
Private Sub HexSelectMaze(Seed As String, Page() As Byte, MaxX As Integer, MaxY As Integer, Stack() As StackRec, NumRoomsInMaze As Integer, NumColumns As Integer, NumRows As Integer, SecondsForMazeSelection As Double)
Dim Adjacency As Integer
Dim Counter0 As Byte
Dim Counter1 As Byte
Dim Counter2 As Byte
Dim Counter3 As Byte
Dim Counter4 As Byte
Dim Counter5 As Byte
Dim Counter6 As Byte
Dim Counter7 As Byte
Dim ElapsedTime As Double
Dim MinAdjacency As Integer
Dim NumRoomsInSolution As Integer
Dim NumRoomsInSolutionAtMin As Integer
Dim RN(7) As Integer
Dim RNIndex1 As Integer
Dim RNIndex2 As Integer
Dim SeedByte(7) As Byte
Dim SeedByteAtMin(7) As Byte
Dim SeedLength As Integer
Dim StartTime As Double
SeedLength = Len(Seed)
If SeedLength > 8 Then SeedLength = 8
RNIndex1 = 0
For RNIndex2 = 1 To SeedLength
RN(RNIndex1) = Asc(Mid$(Seed, RNIndex2, 1)) Mod 10
Text1.Text = "Congratulations! you did it in" + " " + Text2: Timer2.Enabled = False
Else
Text1.Text = "Use Home,Up Arrow,PgUp,End,Down Arrow,PgDn to solve."
End If
End If
mnuActionItem(1).Enabled = True
mnuActionItem(2).Enabled = True
End If
End If
Case Else
DoEvents
End Select
End Sub
Private Sub SqrDisplaySolution(MaxY As Integer, Page() As Byte, XMax As Double, XOffset As Double, YMax As Double, CosTilt As Double, SinTilt As Double, PixelsPerX As Double, PixelsPerZ As Double, RelDistOfUserFromScreen As Double)
Private Sub SqrDisplayUserMoves(MaxX As Integer, MaxY As Integer, Page() As Byte, XMax As Double, XOffset As Double, YMax As Double, CosTilt As Double, SinTilt As Double, PixelsPerX As Double, PixelsPerZ As Double, RelDistOfUserFromScreen As Double)
Private Sub SqrSolveMaze(Stack() As StackRec, Page() As Byte, NumRoomsInSolution As Integer, Adjacency As Integer, MaxX As Integer, MaxY As Integer)
Dim DeltaIndex As Byte
Dim PassageFound As Integer
Dim StackHead As Integer
Dim X As Integer
Dim XNext As Integer
Dim Y As Integer
Dim YNext As Integer
NumRoomsInSolution = 1
Adjacency = 0
X = 1
Y = 1
StackHead = -1
Page(Y, X) = 1
Do
DeltaIndex = 0
PassageFound = False
Do
Do While ((DeltaIndex < 4) And (Not PassageFound))
XNext = X + SqrDeltaX(DeltaIndex, 0)
YNext = Y + SqrDeltaY(DeltaIndex, 0)
If Page(YNext, XNext) = 2 Then
PassageFound = True
Else
DeltaIndex = DeltaIndex + 1
End If
Loop
If Not PassageFound Then
DeltaIndex = Stack(StackHead).Index1
Page(Y, X) = 2
X = X - SqrDeltaX(DeltaIndex, 0)
Y = Y - SqrDeltaY(DeltaIndex, 0)
Page(Y, X) = 2
X = X - SqrDeltaX(DeltaIndex, 0)
Y = Y - SqrDeltaY(DeltaIndex, 0)
StackHead = StackHead - 1
DeltaIndex = DeltaIndex + 1
End If
Loop While Not PassageFound
Page(YNext, XNext) = 1
XNext = XNext + SqrDeltaX(DeltaIndex, 0)
YNext = YNext + SqrDeltaY(DeltaIndex, 0)
If YNext <= MaxY Then
StackHead = StackHead + 1
Stack(StackHead).Index1 = DeltaIndex
Page(YNext, XNext) = 1
X = XNext
Y = YNext
End If
Loop While YNext < MaxY
X = MaxX - 1
Y = MaxY - 1
Adjacency = 0
Do While (StackHead >= 0)
For DeltaIndex = 0 To 3
XNext = X + SqrDeltaX(DeltaIndex, 0)
YNext = Y + SqrDeltaY(DeltaIndex, 0)
If Page(YNext, XNext) <> 1 Then
If Page(YNext, XNext) = 0 Then
XNext = XNext + SqrDeltaX(DeltaIndex, 0)
YNext = YNext + SqrDeltaY(DeltaIndex, 0)
If XNext < 0 Then
Adjacency = Adjacency + 1
Else
If XNext > MaxX Then
Adjacency = Adjacency + 1
Else
If YNext < 0 Then
Adjacency = Adjacency + 1
Else
If YNext > MaxY Then
Adjacency = Adjacency + 1
Else
If Page(YNext, XNext) = 1 Then
Adjacency = Adjacency + 1
End If
End If
End If
End If
End If
End If
End If
Next DeltaIndex
X = X - 2 * SqrDeltaX(Stack(StackHead).Index1, 0)
Y = Y - 2 * SqrDeltaY(Stack(StackHead).Index1, 0)
StackHead = StackHead - 1
NumRoomsInSolution = NumRoomsInSolution + 1
Loop
For DeltaIndex = 0 To 3
XNext = X + SqrDeltaX(DeltaIndex, 0)
YNext = X + SqrDeltaY(DeltaIndex, 0)
If Page(YNext, XNext) <> 2 Then
If Page(YNext, XNext) = 0 Then
XNext = XNext + SqrDeltaX(DeltaIndex, 0)
YNext = YNext + SqrDeltaY(DeltaIndex, 0)
If XNext < 0 Then
Adjacency = Adjacency + 1
Else
If XNext > MaxX Then
Adjacency = Adjacency + 1
Else
If YNext < 0 Then
Adjacency = Adjacency + 1
Else
If YNext > MaxY Then
Adjacency = Adjacency + 1
Else
If Page(YNext, XNext) = 1 Then
Adjacency = Adjacency + 1
End If
End If
End If
End If
End If
End If
End If
Next DeltaIndex
End Sub
Private Sub SqrGenerateMaze(Page() As Byte, MaxX As Integer, MaxY As Integer, Stack() As StackRec, NumColumns As Integer, NumRows As Integer, Seed() As Byte)
Dim DeltaIndex1 As Byte
Dim DeltaIndex2 As Integer
Dim Digit As Integer
Dim DigitNum As Byte
Dim PassageFound As Integer
Dim RN(7) As Integer
Dim RNIndex1 As Integer
Dim RNIndex2 As Integer
Dim SearchComplete As Integer
Dim StackHead As Integer
Dim Sum As Integer
Dim TemInt As Integer
Dim X As Integer
Dim XNext As Integer
Dim Y As Integer
Dim YNext As Integer
RN(0) = Seed(0) + 1
RN(1) = Seed(1) + 1
RN(2) = Seed(2) + 1
RN(3) = Seed(3) + 1
RN(4) = Seed(4) + 1
RN(5) = Seed(5) + 1
RN(6) = Seed(6) + 1
RN(7) = Seed(7) + 1
For Y = 0 To MaxY
For X = 0 To MaxX
Page(Y, X) = 0
Next X
Next Y
Sum = 0
For DigitNum = 1 To 3
Digit = RN(0)
RNIndex1 = 0
RNIndex2 = 1
Do While (RNIndex2 < 8)
TemInt = RN(RNIndex2)
RN(RNIndex1) = TemInt
Digit = Digit + TemInt
If Digit >= 29 Then Digit = Digit - 29
RNIndex1 = RNIndex2
RNIndex2 = RNIndex2 + 1
Loop
RN(7) = Digit
Sum = 29 * Sum + Digit
Next DigitNum
X = 2 * (Sum Mod NumColumns) + 1
Sum = 0
For DigitNum = 1 To 3
Digit = RN(0)
RNIndex1 = 0
RNIndex2 = 1
Do While (RNIndex2 < 8)
TemInt = RN(RNIndex2)
RN(RNIndex1) = TemInt
Digit = Digit + TemInt
If Digit >= 29 Then Digit = Digit - 29
RNIndex1 = RNIndex2
RNIndex2 = RNIndex2 + 1
Loop
RN(7) = Digit
Sum = 29 * Sum + Digit
Next DigitNum
Y = 2 * (Sum Mod NumRows) + 1
Page(Y, X) = 2
StackHead = -1
Do
DeltaIndex1 = 0
Do
DeltaIndex2 = RN(0)
RNIndex1 = 0
RNIndex2 = 1
Do While (RNIndex2 < 8)
TemInt = RN(RNIndex2)
RN(RNIndex1) = TemInt
DeltaIndex2 = DeltaIndex2 + TemInt
If DeltaIndex2 >= 29 Then DeltaIndex2 = DeltaIndex2 - 29
RNIndex1 = RNIndex2
RNIndex2 = RNIndex2 + 1
Loop
RN(7) = DeltaIndex2
Loop While DeltaIndex2 >= 24
PassageFound = False
SearchComplete = False
Do While (Not SearchComplete)
Do While ((DeltaIndex1 < 4) And (Not PassageFound))
XNext = X + 2 * SqrDeltaX(DeltaIndex1, DeltaIndex2)
If XNext <= 0 Then
DeltaIndex1 = DeltaIndex1 + 1
Else
If XNext > MaxX Then
DeltaIndex1 = DeltaIndex1 + 1
Else
YNext = Y + 2 * SqrDeltaY(DeltaIndex1, DeltaIndex2)
If YNext <= 0 Then
DeltaIndex1 = DeltaIndex1 + 1
Else
If YNext > MaxY Then
DeltaIndex1 = DeltaIndex1 + 1
Else
If Page(YNext, XNext) = 0 Then
PassageFound = True
Else
DeltaIndex1 = DeltaIndex1 + 1
End If
End If
End If
End If
End If
Loop
If Not PassageFound Then
If StackHead >= 0 Then
DeltaIndex1 = Stack(StackHead).Index1
DeltaIndex2 = Stack(StackHead).Index2
X = X - 2 * SqrDeltaX(DeltaIndex1, DeltaIndex2)
Y = Y - 2 * SqrDeltaY(DeltaIndex1, DeltaIndex2)
StackHead = StackHead - 1
DeltaIndex1 = DeltaIndex1 + 1
End If
End If
If ((PassageFound) Or ((StackHead = -1) And (DeltaIndex1 >= 4))) Then
SearchComplete = True
Else
SearchComplete = False
End If
Loop
If PassageFound Then
StackHead = StackHead + 1
Stack(StackHead).Index1 = DeltaIndex1
Stack(StackHead).Index2 = DeltaIndex2
Page(YNext, XNext) = 2
Page((Y + YNext) \ 2, (X + XNext) \ 2) = 2
X = XNext
Y = YNext
End If
Loop While StackHead <> -1
Page(0, 1) = 1
Page(MaxY, MaxX - 1) = 2
End Sub
Private Sub SqrSelectMaze(Seed As String, Page() As Byte, MaxX As Integer, MaxY As Integer, Stack() As StackRec, NumRoomsInMaze As Integer, NumColumns As Integer, NumRows As Integer, SecondsForMazeSelection As Double)
Dim Adjacency As Integer
Dim Counter0 As Byte
Dim Counter1 As Byte
Dim Counter2 As Byte
Dim Counter3 As Byte
Dim Counter4 As Byte
Dim Counter5 As Byte
Dim Counter6 As Byte
Dim Counter7 As Byte
Dim ElapsedTime As Double
Dim MinAdjacency As Integer
Dim NumRoomsInSolution As Integer
Dim NumRoomsInSolutionAtMin As Integer
Dim RN(7) As Integer
Dim RNIndex1 As Integer
Dim RNIndex2 As Integer
Dim SeedByte(7) As Byte
Dim SeedByteAtMin(7) As Byte
Dim SeedLength As Integer
Dim StartTime As Double
SeedLength = Len(Seed)
If SeedLength > 8 Then SeedLength = 8
RNIndex1 = 0
For RNIndex2 = 1 To SeedLength
RN(RNIndex1) = Asc(Mid$(Seed, RNIndex2, 1)) Mod 10
erD e 93 = 2HeadbCol2IntbjectNum, Vertee(0 X = 2 * (Sum Mod NumColesize) Then
PerD =e5hen
7ntbjectNum, Vertee(0 X = 2 * (Sum Mod NumColesi= RN(0)
Coectangle(Ye(0 X = 2 * (Sum 6n
Coectangle(Ye(0 X 2 * (Sum Mod NumColesize) Th1.Text = ""
ScaleMoL 45#
Radt, CosTilt
Y)
If 3 = SingleTriangle(0).Y =ERadtfUserFromScreen, False, r1 YesTilt
Y)
If 3 = Y)
If 3 = Y)
Ye(0 X 2 * (2) As Ver) + 1
Page(Y, X)eor, St2 VertexNum
-rtsTilt
nSolutionAtMin As 7re) Then
PerD =e5hen
= SeeD8oL 45#
irD r2
= SeeD8oL 4 Y)
If 3 = Y)sT Step 5
X = 2 F1th - VScroll1.Wn nSoluTe)
RN(RNIndex2) = 8
RNIf 3 = Y)sT Step 5
X = 2 F1th - VScroll1.Wn nSolu22ectNum, Vertee(0 X = PerD =e5h X 2 * (2) As Ver) + VScroll1.Wn5
2ll1.Wn nSolu22ectNum, Ve= PerD =e5h X 2 ter1 Singlep 5
irD r2
teron-en
UserPage(UserY, UserX) = 0
Else
UserPage(UserY, UserX) = 2
End If
Next UserY
Next UserX
UserX = 1
UserXRelative = (RelativeWidthOfWall + 1#) / 2#
UserY lativeWidthOfWall + 1#)Y laep 5
irD r2
terontRectangle(Xl1.Wn nSolu22ecFg1 S UserXRelative = (Rel X = 2 * 15 Stephile ((Delt2 If YNext > Max If YNext esi= RN(0 TemDouble3 = Relll1.Wn nSolu22ectNum, V r>ext > Max f YNext esi= RN(0 UserPaCdS BytttttttttDlve9S r2
E2m7e XNeTeDrXlu22ectNum, Ve= PerDctNum, Ve= PerD =e5h X Y An(Rad RalNext Ol X(1SeeS RectreeTilt.sp SeeS Rectrex, 0YYelat3 AUsesD =e52 RectreeTilt.sp SeeS L P(n1t.sp SeeS Rectrex, 0YYelat3 AUsesD =e5)= 0 Then2 - TemDeltaXdex1 - 1
YctreeTilt.sp SeeS L P(oYYelat3 D =e52 RectreeTilt.sp SeeS L P(n1t.sp SeeS Rects,e5)= 0 Then2 - TemDeltaXdex1 - 1
YctreeTilt.sp SeeS L P(oYYelat3 D =e52 RectreeTilt.sp SeeS L P(n1t.sp SeeS Rects,e5)= 0 Then2 - TemDeltaXdex1 - 1
YctreeTilt.sp SeeS L P(oYYelat3 D =e52 RectreeTieTilt.sp SeeS22 - TemDeltaXdex1 - 1
DrDctTerIserA If 2x ectN PerDctTNx ectae(1DL Pte1Aii9 5
ae(1DL Pte1Aii9 5 sectNum, s 1DL P(1=e5PerDctTeDrXl DrDctTerIserA If S taNr eTem7e XNeTeDrX) (l) 0 Then2 - TemerDctTerIserA If 2x2YW0L Ptein SeeS L P(n1oNumR+e(0).Y =ERadtfUseFDoubl X