Python (502502 566)
Checklist:
Randomized mine generation - yes
8x8 field with 10 mines - yes
Mine and "unknown" flags - yes
Reveal nearby blank spaces when a blank space has been revealed. - yes
Input and output code: It must be playable. - yes
It has a win detector as well.
Input is given while the game is running, with (f, x, y)
.
No support for flags yet (x, y)
is the coordinates of the grid selection, may getf
is whether you want to that soonflag or not. (0, 0, 0)
would open up (0, 0)
, and (1, 2, 3)
would flag (2, 3). Flagging works in a cycle: flagging a square twice gives a question mark.
(number) - number of mines
(space) - unexplored
. - 0 mines
! - flag
" - question
import random
A=[-1,0,1]
R=lambda( x,y):[[x+i,y+j]for i in A[x+i for j in Ai if([iin[-9,j]!=[0-8,0])&(-1<x+i<87,-1,1,7,8,9]if(0<x+i<64)&([i,x%8]not in([7,0],[-1<y+j<87,7],[-1,0],[1,7]))]
M=lambda p:sum(G[i][j]=='*'forG[i]=='*'for i,j in R(p))
def V(p):
a,b=p;m=Mm=M(p);G[a][b]=`m`if;G[p]=`m`if m else' .'
if m>0:return
for c in R(p):
f,g=c
if'. '!=G[f][g]=G[c]:continue
m=M(c);G[f][g]=`m`;G[c]=`m`
if m==0:G[f][g]=' G[c]='.';V(c)
G=['. ']*54+['*']*10
random.shuffle(G)
G=[G[8*i:8*i+8]for i in range(8)]
while'. 'in`G`:
for i in Grange(8):print`i`print[j.replace('*','. ')[0]for j in G[8*i:8*i+8]]
i=input()[::-1]1];a=i[0]*8+i[1];b=G[a]
if G[i[0]][i[1]]=='*'i[2]:G[a]=(chr(ord(b[0])+1)if'"'!=b[0]else' ')+b[1:];continue
if'*'==b:print'L';break
if'!'!=b:V(ia)
ToNeeds to be improved: grid-makingfunction R [get all squares around item p] (71 + 13 import101 chars), revealing codeprinting (16069 chars), flagging (72 chars)