Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Maze and Snake!

by chipmunk (Parson)
on Aug 15, 2001 at 19:55 UTC ( [id://105074]=obfuscated: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $x=1+rand($w=pop||33);$y=1+rand($h=pop||9);sub p{print@_}@m=($t=[10
    ,(8)x($w+1)],(map[(2,(0)x$w,2)],1..$h),$t);sub w{$m[$y][$x]|=$_}{(@d=
    ($m[$y-1][$x]?():1,$m[$y+1][$x]?():2,$m[$y][$x-1]?():4,$m[$y][$x+1]?()
    ...
    ||s/4/$x--;8/e||s/8/$x++;4/e,w):(($y,$x)=@{shift@q||last});redo}sub r{
    $m[pop][1+rand$w]|=2}r;r-2;for$y(0..$h){p$",$m[$y][$_]&8?$":'#'for@w=
    0..$w;sub P{p" \n"}P;p$m[$y][$_]&2?$":'#','#'for@w;P}p$"x(2+$w*2);P
    
  2. or download this
    $|=@j='Just another Perl hacker, '=~/./gs;sub p{print@_}p$H="\e[H",
    "\e[J",map@$_,@m=map[//g],<>;@y=$"='';$_="@{$m[1]}";/\S+/g;p"$H ",' '
    x($x[0]=pos);$_=C;{$o=0;$y=$y[-1];$x=$x[-1];s|A|$m[$y][++$x]=~/ /?$o=C
    ...
    s|D|$m[--$y][$x]=~/ /?$o=A:B|e;$o||redo;$y^$y[-2]||$x^$x[-2]?($y[@y]=$
    y,$x[@x]=$x):(--$#y,$#x--,$j-=2,p"\e[D ");$y&&$x&&$y<$#m&$x<$#{$m[0]}
    &&do{p"\e[$_\e[D$j[$j++]";$j%=@j;select$,,$,,$,,.06;redo}}p$H,$/x@m
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://105074]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found