'-------------------------' maze 'Author: Saibei snow' Date: March 2005 'as the matrix below, the upper left corner For the entrance, the upper right foot is export, 0 is expressed, 1 means blocking '00001100' 11001001 '01000110' 00010000 '00000100' 'This program automatically generates a labyrinth, then automatically search for the result of the road': '{0,0 } {1,0} {2,0} {3,0} {3, 1} {3, 2} {4, 2} {4, 3} {5, 3} {6,3} {7,3 } {7,4} '-------------------------
'Coordinate Point Class Point Public X Public Y Private Sub Class_Initialize () x = 0 y = 0 End Subend Class
'Creating a PointSub CreatePoint (Byref Opoint, Ox, Oy) Set opoint = new point opoint.x = ox opoint.y = yend sub
'Compare two PointFunction ComparePoint (Byref P1, Byref P2) IF (p1.x = p2.x and p1.y = p2.y) Then ComparePoint = 1 else comparePoint = 0 End IFEND FUNCTION
'Find PointFunction Findpoint in the Point array, pcount) if (Pcount> 0) Then for i = pcount-1 to 0 step -1 if ComparePoint (P1, PARRAY (i)) = 1 Ten FindPoint = 1 EXIT FUNCTION END IF NEXT End IF FindPoint = 0nd Function '-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Creating a maze array SUB Createmigong (M9, N9, BYREF Li9) Redim Li9 (M9, N9) for i = 0 to M9-1 for J = 0 to N9-1 LiU9 (i, j) = Createrand () Next Nextend SUB
'Show maze input array SUB Showmigong (m9, n9, liu9) for i = 0 to m9-1 for j = 0 to N9-1 Response.write Round (LiU9 (i, j), 2) Next response.write < Br> "Nextend Sub
'Creating a random 1 or 0Function Createrand () DIM RNDTEMP RANDOMIZE (TIME ()) RndTemp = RND IF RNDTEMP> 0.8 Ten Createrand = 1 else creagerand = 0 End IFEND FUNCTION
'Expand a Point array sub EnlargeArray (byref pArray, addStep, byref pLen) pLen = pLen addStep redim preserve pArray (pLen-1) end sub' array add a specified Point (p1) sub AppendPath (byref pArray, byref pLen , byref parraylen, byref p1) IF (Plen> = parraylen) Then Enlarray Parray, OSTEP, PARRAYLEN END IF PLEN = Plen 1 Set Parray (Plen-1) = P1END SUB
Add a Point in an array ----- According to X, Y Generates a PointSub AppendPath2 (Byref Parray, Byref Plen, Byref Parraylen, X1, Y1) IF (Plen> = PARRAYLEN) THEN Enlargua Parray, OSTEP, PARRAYLEN END IF Plen = Plen 1 CreatePoint Apoint, X1, Y1 Set Parray (Plen-1) = Apointend Sub
'Delete a PointSub Delpoint from an array if Plen> 0 Then Plen = Plen-1 Set Parray (Plen) = Nothing End IFEND SUB
'Print path sub PrintPath (pArray, pLen) Response.Write "
========= pass =========
" for i = 0 to pLen-1 Response.write "{" & parray (i) .x & "& parray (i) .y &"} "Nextend Sub
'Output maze errors, this is a labyrinth subprinterr response.write without an entrance or without an exit! "End Sub
Sub Printmigong (M9, N9, Liu9, Opath9, Pathlen9) Response.write "
========= Maze Road is schematically =========
" response.write "