Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Do you know where your variables are?
 
PerlMonks  

Tic tac toe

by Jeff Connelly (Acolyte)
on Aug 17, 2000 at 10:57 UTC ( #28276=obfuscated: print w/ replies, xml ) Need Help??

295 characters. Can anyone come up with a shorter one?
$_="- - -\n"x3; $"=o;W:while($"=($"eq x?o:x)){$i=0;$O=$_;$O =~s/-/$i++/ge;print$O.$";$H=<>;$w=0;s/-/$w++==$H?$":$&/egs ;$B=$_;for$P(o,x){s/$P{3}/$&/;s/($P . .\n){3}/$&/; s/(. $P .\n){3}/$&/;s/(. . $P\n){3}/$&/; s/$P . .\n. $P .\n. . $P/$&/;s/. . $P\n. $P .\n$P . ./$&/; last(W)if$&=~m/o|x/}$_=$B}print

Comment on Tic tac toe
Download Code
RE: Tic tac toe
by BigJoe (Curate) on Aug 17, 2000 at 16:36 UTC
    Pretty slick but there is no way to exit.

    --BigJoe

    Learn patience, you must.
    Young PerlMonk, craves Not these things.
    Use the source Luke.
      It exits when one of the players wins.

      Slick piece of code BTW.

      /\/\averick

        Tried that and it didn't exit. i had 3 accross the middle just playing. Then I went and filled every one and it still didn't let me out.

        --BigJoe

        Learn patience, you must.
        Young PerlMonk, craves Not these things.
        Use the source Luke.
RE: Tic tac toe
by ChuckularOne (Parson) on Aug 17, 2000 at 21:46 UTC
    Way cool! The cntl-C works fine for me as an exit! I can tell when there's been a winner ;) even on the occasions the program doesn't notice.

    Your Humble Servant,
    -Chuck
Re: Tic tac toe
by vek (Prior) on Jul 05, 2003 at 13:56 UTC

    Extremely late to the party but I had to comment. Very slick, nice job :-)

    -- vek --
Re: Tic tac toe
by delirium (Chaplain) on Jun 04, 2004 at 13:57 UTC
    Can anyone come up with a shorter one?
    Only 4 years late, but yes:
    @r=(123,456,789,147,258,369,159,357);$,=$/;$p=X; sub d{print@r[0..2],$p;die$_[0]if@_} n:d;$m=<>until grep$m=~/\d/&&s/$&/$p/,@r; d"Tie"if!map/\d/,@r;d$p if map/$p{3}/,@r; $p=~tr/XO/OX/;goto n
    190 characters.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-04-20 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls