Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
laziness, impatience, and hubris
 
PerlMonks  

I'm bored, let's play a game

by Anonymous Monk
on Nov 12, 2001 at 19:38 UTC ( #124845=obfuscated: print w/ replies, xml ) Need Help??

Not really obfuscated, just hard to read because I was trying to shorten it enough so that Netscape would let me use it as a sig file. I wrote it with 5.6.0 outputting in a bash shell, and I'm quite sure it's not terribly portable. You'll have to trim out the red '+'s, and join those lines, I think, to get it to run right.
@a=0..63;g(o($_),a($_)?$_<24?"w":$_>39?"b":0:0)for@a;$w=$b=12;while($w +&&$b) {$z=!$z if!$r;$i=" 01234567\n";print$i,(join"",map{($x,$y)=o($_);($x?" +":$y) .(a($_)?`tput smso`:`tput rmso`).(g(o($_))||" ").`tput rmso`.($x==7?"$ +y\n": "")}@a),$i;$z?&n:&c;g($f,$g,($g==7&&$z)||!($z||$g)?uc&w:g($d,$e));g($d +,$e,0 );t(1)}sub n{print"$_[0]xyxy?\n";($d,$e,$f,$g)=split"",<STDIN>;&v||&n} +sub t{ @t=($f>$d?$d+1:$d-1,$g>$e?$e+1:$e-1);if($s==4&&g(@t)&&lc(g(@t))ne&w +){if( @_){g(@t,0);$z?--$b:--$w;&b}1}else{0}}sub v{$s=($d-$f)**2;(lc(g($d,$e) +)ne&w ||$s!=($e-$g)**2||g($f,$g)||$f>7||$f<0||$g>7||$g<0||(($z?$e-$g:$g-$e)> +0)&&! (g($d,$e)eq uc&w)||!($s==1||t())||($r?$d!=$c||$e!=$h:0))?0:1}sub c{for +(@a){ ($d,$e)=o($_);if(lc(g(o($_)))eq&w){for(@a){($f,$g)=o($_);&t?return:pus +h@q,[ $d,$e,$f,$g]if&v}}}($d,$e,$f,$g)=@{$q[$#q]}}sub w{$z?"w":"b"}sub o{($_[0]%8,int($_[0]/8))}sub a{($_[0]%8+int($_[0]/8))%2}sub g{$n=$_[0]+8*$_[1];defined$_[2]?$j[$n]=$_[2]:$j[$n]}sub b{$d=$c=$f;$e= +$h=$g ;$r=(grep{($f,$g)=o($_);&v&&t()}@a)?1:0}die$w?"win":"lose"."\n"
I was happy for it to come in under 1k (1 byte under)

Comment on I'm bored, let's play a game
Download Code
Re: I'm bored, let's play a game
by kwoff (Friar) on Nov 12, 2001 at 22:15 UTC
    WOW... that is AMAZING!

    (win at ./game.pl line 15, <STDIN> line 27. ;)

(jeffa) Re: I'm bored, let's play a game
by jeffa (Chancellor) on Nov 12, 2001 at 23:01 UTC
    Awesome!!

    Don't worry about the +'s - that's what the d/l code link is for. Good job!

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    F--F--F--F--F--F--F--F--
    (the triplet paradiddle)
    
Re: I'm bored, let's play a game
by chipmunk (Parson) on Nov 13, 2001 at 04:13 UTC
    That's really clever! One small point; the game should end when a player is unable to move on their turn. For example, in this situation, black is unable to move, so white wins:
    01234567 0 w w # #0 1b # # # 1 2 # # # w2 3w # # # 3 4 # W w #4 5# # # # 5 6 # # # #6 7# # # # 7 01234567
      yes, there's another bug, where if you jump, and are able to jump again, but don't, and just move, the game sort of hangs, repeatedly asking you for a move, and then telling you it's invalid. Ah well, release 1.001 coming up, I guess.
Re: I'm bored, let's play a game
by jclovs (Sexton) on Nov 14, 2001 at 01:33 UTC
    Well, you were wrong on the portability. It ran just fine on a bash shell with Perl 5.005_3 although I guess I'm still in a bash shell as you. Great Job!
Re: I'm bored, let's play a game
by spartan (Pilgrim) on Nov 14, 2001 at 21:12 UTC
    It seems a shame that this was posted as anonymous. It deserves a ++ to the creator. Well done!
    -spartan

    Very funny Scotty... Now PLEASE beam down my PANTS!
      Holy cow! That's great! Fun to play, and written in Perl... very very cool... Congrats on the great script.

      Make something idiot proof and they'll make a better idiot.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2014-04-17 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (443 votes), past polls