Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi,

I like the idea of a simple minesweeper, and tried to make one myself :)

Mine doesn't check user input and doesn't auto-sweep, but it fits in 5 lines :)
It tests if the user won, and if so, quits the game.

map$f[rand 8][rand 8]=1,0..9;@u=map[(',')x8],1..8;for(;$i=-2;){print$ i+++2?$i:' '," @$_\n"for[0..7],@u;($x,$y,$f)=split' ',<>;$f?$u[$y][$x ]='F':$u[$y][$x]ne'F'&&$f[$y][$x]&&die||do{$m=' ';for$z(-1..1){$y+$z> -1&&$x+$_>-1&&$f[$y+$z][$x+$_]&&$m++for-1..1}$u[$y][$x]=$m};for$z(0.. 7){for$q(0..7){$_=$u[$z][$q],$i+=$f[$z][$q]?!/^F/:/F/}}$i<8&&die"\n"}


Open (and unflag if flagged) using "x y" ("0 0"), flag with "x y 1" ("0 0 1").

Update (200201161311+0100) Bugs fixed, better checking scan
Update (200201191544+0100) A previous bugfix introduced 3 new ones, making the game a bit unpredictable ;) Fixed now.
Update (200201200039+0100) I need more sleep. Okay, I believe it's really playable now (I actually tried it this time (kick me not))
0 1 2 3 4 5 6 7 0 1 , 1 1 , , , 2 1 1 1 , , , 3 1 , , 1 , , , 4 , , , 2 1 , , , 5 , , , , , , , , 6 , , , , , 2 1 1 7 , , , , , 1 6 0 Died at mine.pl line 3, <> line 29.
As you can see, I'm not very good at this game :)

2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$


In reply to Re: YAMineSweeper by Juerd
in thread YAMineSweeper by giulienk

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 cooling their heels in the Monastery: (16)
    As of 2014-07-28 13:58 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (200 votes), past polls