Re: To: Evan Marshall (Maze Maker)

new topic     » goto parent     » topic index » view thread      » older message » newer message

I'm going to try to go through my original and speed it up before I look 
at yours.  Then I'll look at this code and see how (if at all) similar 
the two are.

Don Phillips wrote:

>
>>I'm glad you found it interesting.  I was thinking about making a 3D 
>>maze and decided a 2D one would be easier to start with.
>>I found an algorithm very similar to yours somewhere on the net (I can't 
>>
>>remember where :(   ) and decided to go for simplicity(?) over speed for 
>>
>>the first draft.  I plan on going back to increase the speed later, as 
>>right now I have more time to wait for a program to run than I do to 
>>develop it!
>>I am also going to make the maze printable and am working on a print 
>>preview routine.  (That should take me quite awhile!)
>>
>>Don Phillips wrote:
>>
>
>Yes, I found it very interesting.  Its good to try something new every 
>once in a while and optimizing this code was alot of fun.  I was able to 
>speed it up even further and reduce the code in the main loop quite a 
>bit from the one I posted last.  Also I was able to make the status 
>indicator consistant in movement.
>
>I think I like this version the best.  Not only is it faster, shorter, 
>and easier to understand, I believe it makes better overall (and harder) 
>mazes to solve.
>
>-=-=-=-=-=-=-=-=-=-
>
>without warning
>include Win32Lib.ew
>
>-- register controls with win32lib
>constant
>MainWin		= create( Window, "Maze", NULL, 0.1, 0.1, 0.8, 0.8, 
>or_all({WS_CLIPCHILDREN,WS_CLIPSIBLINGS}) ),
>Canvas		= create( Window, "", MainWin, 0, 0, 1, 1, 
>{WS_CHILD,WS_VISIBLE,WS_DLGFRAME,WS_CLIPCHILDREN,WS_CLIPSIBLINGS} ),
>MaxXLbl		= createEx( EditText, "", Canvas, 14, 7, 50, 15, 
>{WS_CHILD,WS_VISIBLE,WS_DISABLED}, {0} ),
>MaxYLbl		= createEx( EditText, "", Canvas, 74, 7, 50, 15, 
>{WS_CHILD,WS_VISIBLE,WS_DISABLED}, {0} ),
>EditX		= create( EditText, "20", Canvas, 10, 22, 50, 20, ES_NUMBER ),
>EditY		= create( EditText, "20", Canvas, 70, 22, 50, 20, ES_NUMBER ),
>RunMaze		= create( DefPushButton, "Make Maze", Canvas, 131, 18, 140, 29, 
>0 ),
>Status		= create( ProgressBar, "", Canvas, 0, 0, 1, 1, 0 )
>
>-- define globals
>sequence	NewPos
>
>-- remove a wall in specified direction
>procedure RemoveWall( integer Direction )
>	if Direction = 1 then
>		drawLine( MainWin, (NewPos[1]-1)*10+1, (NewPos[2]-1)*10, 
>(NewPos[1]-1)*10+10, (NewPos[2]-1)*10 )
>	elsif Direction = 2 then
>		drawLine( MainWin, (NewPos[1]-1)*10, (NewPos[2]-1)*10+1, 
>(NewPos[1]-1)*10, (NewPos[2]-1)*10+10 )
>	elsif Direction = 3 then
>		drawLine( MainWin, (NewPos[1]-1)*10+10, (NewPos[2]-1)*10+1, 
>(NewPos[1]-1)*10+10, (NewPos[2]-1)*10+10 )
>	else
>		drawLine( MainWin, (NewPos[1]-1)*10+1, (NewPos[2]-1)*10+10, 
>(NewPos[1]-1)*10+10, (NewPos[2]-1)*10+10 )
>	end if
>end procedure
>
>-- make the maze
>procedure makeMaze()
>	integer Direction
>	integer Index
>	integer PosX
>	integer PosY
>	integer	RoomsX
>	integer	RoomsY
>	integer	UsedRooms
>	sequence Grid
>	sequence Mask	
>	sequence Move	
>	sequence Path
>	sequence Size
>	sequence Slice
>
>	-- clear screen
>	repaintWindow( MainWin )
>
>	-- get size of grid
>	Size = value( getText(EditX) )
>	RoomsX = Size[ 2 ]
>	Size = value( getText(EditY) )
>	RoomsY = Size[ 2 ]
>
>	-- enforce maximums
>	Size = getClientRect( MainWin )
>	if RoomsX > floor((Size[3] - 20) / 10) then
>		setText( EditX, sprintf( "%d", {floor((Size[3] - 20) / 10)} ))
>		RoomsX = floor((Size[3] - 20) / 10)
>	end if
>	if RoomsY > floor((Size[4] - 80) / 10) then
>		RoomsY = floor((Size[4] - 80) / 10)
>		setText( EditY, sprintf( "%d", {floor((Size[4] - 80) / 10)} ))
<snip>

>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu