#打开第r行第c列的雷区,若是雷返回False
def openm(r,c):
if openmap[r][c]!=-1: #已打开
return True
n=minemap[r][c]
openmap[r][c]=n
if n==-1: #中奖了
return False
if n==0: #递归打开无雷区域
ar=((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1))
for a in ar:
if 0<r+a[0]<ps+1 and 0<c+a[1]<ps+1:
openm(r+a[0],c+a[1])
return True
网友评论