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:~$
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.