Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!/usr/bin/perl sub r{int rand pop}$|++;@g=map{[map{' '}0..$=]}0..25;my$j=pop||2+r(3); +@f=map{my$ k=my$n=$b++;my$z=1;my$x=r$=;my($q,$v,$e)=my@l=(0,0,0,0);my$h=r(9);$w={ +i=>sub{$k= r($j) while($k==$n or!$f[$k]);my$o=$f[$k];$h+=($e?-1:1);if($h<1){$e=0; +$k=$n}if($ h>6){$e=1}if(!$z){my$u=($x<$$o{x}->()?1:-1);$u*=(($e>1)?-1:1);$q=$e?($ +u*(r(7))): 0;if($e>1){$q||=4}if($e and(r(7)>3)){$v=r(6)}}my$t=($$o{z}->()cmp$z)+1 +;$t=0 if($ x==$$o{x}->());my$s=(($x<$$o{x}->())?1:0);for(0,2){$l[$_+$s]+=($t cmp$ +l[$_+$s])} for(0,2){$l[$_+($s?0:1)]=0}if($z){$v-=2}$x+=$q;$z+=$v;$z=0 if$z<0;if($ +x<2){$x=2; $q*=-1 if $q<0}if($x>$=-2){$x=$=-2;$q*=-1 if $q>0}if ((abs($x-($$o{x}- +>()))+1)*( 1+abs($z+1-($$o{z}->())))<9){r(2)?($$o{c}->($n) or $e=1):${$f[$n]}{c}- +>($k);}},d =>sub{$g[20-$z][$x]="O";$g[21-$z][$x]="+";$g[22-$z][$x]="|";for(0..1){ +my@c=($_?( '/','-',"\\"):("\\",'-','/'));$g[21-$z][$x+($_?1:-1)]=$l[$_]?'-':$c[2] +;$g[22-$z- $l[$_]][$x+($_?2:-2)]=$c[2-$l[$_]];$g[23-$z][$x+($_?1:-1)]=$l[2+$_]>1? +'-':$c[2]; $g[24-$z-($l[2+$_]>1?1:0)][$x+($_?2:-2)]=$c[$l[2+$_]>1?1:2];}},z=>sub{ +$z},x=>sub {$x},n=>sub{$n=pop},c=>sub{$h=0;$e=2;$k=pop;$q=0;if(!r(7)){splice@f,$n +,1;for(@f) {$$_{n}->($h++)}}}}}1..$j;while(1){++$iter;if(@f==1){exit 0}for$m(@f){ +$$m{i}->() ;$$m{d}->()}print$/x$=;for $a(1..25){print$/,"|",@{$g[$a]},"|";@{$g[$a +]}=map{' ' }0..$=;}sleep 1}#Optional command-line argument selects how many ninja + stickmen.

My joke generator got a complaint about getting lost in all the map transforms, so in an effort to make my code easier to follow (ahem) I have limited myself to only four occurrances of map in this little project, instead using the trinary operator, a lot of conditionals and comparisons, and far too many variables for such a short program. Enjoy :-)

Oh, you can take out the sleep 1 for hyper speed, if desired, which is useful if you want to use the command-line argument to specify large numbers of fighters. 500 ninjas take too long to duke it out with the sleep statement in.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

In reply to Goofy leaping ninja stickmen by jonadab

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (7)
    As of 2014-09-17 21:24 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (99 votes), past polls