User since: Feb 23, 2018 at 18:35 UTC (8 years ago)
Last here: Oct 31, 2020 at 14:27 UTC (5 years ago)
Experience: 57
Level:Acolyte (3)
Writeups: 5
Location:Helsinki, Finland
User's localtime: Dec 20, 2025 at 19:28 UTC
Scratchpad: View
For this user:Search nodes

($w,$h)=(25,10);%l=map{$_,{map{$_,0}1..$h}}1..$w;sub t{my($x,$y)=@_;$l +{$x}{$y}|=1;my@c=grep{exists($l{$$_[0]}{$$_[1]})&&!$l{$$_[0]}{$$_[1]} +&1}map{[$x+$$_[0],$y+$$_[1],$$_[2]]}([-1,0,2],[1,0,2],[0,-1,4],[0,1,4 +]);@c&&do{$c=$c[int(rand(@c))];$l{$x<$$c[0]?$x:$$c[0]}{$y<$$c[1]?$y:$ +$c[1]}|=$$c[2];t(@$c);t($x,$y);}}t(12,5);print join("",map{$y=$_;"X". +join("X",map{$l{$_}{$y}&2?"-":" "}1..$w)."\n".join(" " ,map{$l{$_}{$y}&4?"|":" "}1..$w)."\n" }1..$h);
[download]

The code above is a maze generator.

As you might have guessed I am a programmer. Take a look at my website http://www.pawelbiernacki.net .