Inspired by C.sprinkle's Axe maze generator project, and guided by my own program outline that I wrote for him, I have released a simple DFS (depth-first search) maze generator written in Hybrid BASIC for Doors CS 7.0 and higher. It uses the DCSB Libs' AnsStack feature to efficiently recurse, generating mazes with passages as narrow as one pixel. The wider the passages, the easier the maze; the width parameter is user-selectable at runtime. I'm fairly proud of this as a neat little maze generator, but I feel it is more valuable in its demonstration of the power and simplicity of the AnsStack feature. Thanks once again to Shaun "Merthsoft" McFall for suggesting the feature and for other users for supporting the idea.

Download
DCS DCS Maze Generator v1.0

Cool Very Happy (I'm going to have to look at the source >.>). I had tried to make this using your code, but the "erase 4 of the lines" part kinda confused me.
_player1537 wrote:
Cool Very Happy (I'm going to have to look at the source >.>). I had tried to make this using your code, but the "erase 4 of the lines" part kinda confused me.
Oh, my bad, I meant to post the source. prgmMAZEGEN is first, the main program, and prgmZMAZE is second, the recursion function. I believe that I maxed out my DCS header size in terms of which features I use (except for a 17x17 icon):

BASIC Code wrote:
::"MAZE GENERATOR
::DCS
:"FF81EF85B59591FF
::A
:ZMAZE
::
:If 1337≠det([[42
:Then
:¦ Disp "NEED DOORS CS 7","DCS.CEMETECH.NET
:¦ Return:End
:sum(16
:Input "CORRIDOR WIDTH:",W
:0→Xmin
:94→Xmax
:0→Ymin
:62→Ymax
:AxesOff:ClrDraw
:Wint(94/W
:Line(0,0,Ans,0
:Line(0,0,0,Wint(62/W
:Line(Ans,Wint(62/W),Ans,0
:Line(Ans,Wint(62/W),0,Wint(62/W
:{0,Ans,0,Wint(62/W→L1
:{0,0,0,0,0,0→L2
:prgmZMAZE
:sum(16
:DispGraph
:Pause :ClrHome
:Disp "MAZE GENERATOR","BY Kerm MARTIAN
Generated by SourceCoder, © 2005-2010 Cemetech


BASIC Code wrote:
:Ans
:For(X,1,6
:¦ L2(X:sum(14
:End
:L1→L2
:augment(L2,{L2(1)+WrandInt(1,‾1+(L2(2)-L2(1))/W),L2(3)+WrandInt(1,‾1+(L2(4)-L2(3))/W)→L2
:Line(L2(1),L2(6),L2(2),L2(6
:Line(L2(5),L2(3),L2(5),L2(4
:randInt(1,4→Q
:If Q≠1:Then
:¦ L2(1)+WrandInt(0,‾1+(L2(5)-L2(1))/W
:¦ Line(Ans+1,L2(6),Ans+W-1,L2(6),0
:End
:If Q≠2:Then
:¦ L2(5)+WrandInt(0,‾1+(L2(2)-L2(5))/W
:¦ Line(Ans+1,L2(6),Ans+W-1,L2(6),0
:End
:If Q≠3:Then
:¦ L2(3)+WrandInt(0,‾1+(L2(6)-L2(3))/W
:¦ Line(L2(5),Ans+1,L2(5),Ans+W-1,0
:End
:If Q≠4:Then
:¦ L2(6)+WrandInt(0,‾1+(L2(4)-L2(6))/W
:¦ Line(L2(5),Ans+1,L2(5),Ans+W-1,0
:End
:{L2(1),L2(5),L2(3),L2(6)→L1
:If Ans(2)-Ans(1)>W and Ans(4)-Ans(3)>W
:prgmZMAZE
:{L2(1),L2(5),L2(6),L2(4)→L1
:If Ans(2)-Ans(1)>W and Ans(4)-Ans(3)>W
:prgmZMAZE
:{L2(5),L2(2),L2(3),L2(6)→L1
:If Ans(2)-Ans(1)>W and Ans(4)-Ans(3)>W
:prgmZMAZE
:{L2(5),L2(2),L2(6),L2(4)→L1
:If Ans(2)-Ans(1)>W and Ans(4)-Ans(3)>W
:prgmZMAZE
:For(X,6,1,‾1
:¦ sum(15
:¦ Ans→L2(X
:End
Generated by SourceCoder, © 2005-2010 Cemetech
player_1537, that's where I messed up too. I also was in the process of looking at another variation and trying iterative things too. Anyway, this is excellent, Kerm, and I am sorry that I wasn't able to do it.
c.sprinkle wrote:
player_1537, that's where I messed up too. I also was in the process of looking at another variation and trying iterative things too. Anyway, this is excellent, Kerm, and I am sorry that I wasn't able to do it.
No need to be sorry; I enjoyed writing this. Smile I haven't written any serious TI-BASIC since my DCSB Libs demo apps in July or August, so it was nice to give it a go once again.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement