fixed x-y mishap
This commit is contained in:
parent
7d433d50f3
commit
6b34d11c09
10
minebash.py
Normal file → Executable file
10
minebash.py
Normal file → Executable file
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/env python2
|
||||||
import readline, random, io, sys
|
import readline, random, io, sys
|
||||||
|
|
||||||
import curses
|
import curses
|
||||||
@ -33,12 +33,12 @@ def setup_strings(colcount):
|
|||||||
|
|
||||||
def calculate_hint(col, row):
|
def calculate_hint(col, row):
|
||||||
hint = 0
|
hint = 0
|
||||||
if playfield[col][row] != MINE:
|
if playfield[row][col] != MINE:
|
||||||
for x in range(col-1, col+2):
|
for x in range(col-1, col+2):
|
||||||
if x >= 0 and x < len(playfield)-1:
|
if x >= 0 and x < len(playfield)-1:
|
||||||
for y in range(row-1, row+2):
|
for y in range(row-1, row+2):
|
||||||
if y >= 0 and y < len(playfield[0])-1:
|
if y >= 0 and y < len(playfield[0])-1:
|
||||||
if(playfield[x][y] == MINE):
|
if(playfield[y][x] == MINE):
|
||||||
hint+=1
|
hint+=1
|
||||||
else:
|
else:
|
||||||
hint = MINE
|
hint = MINE
|
||||||
@ -81,8 +81,10 @@ def print_playfield(playfield):
|
|||||||
# did we find a hint?
|
# did we find a hint?
|
||||||
if cell >= 0:
|
if cell >= 0:
|
||||||
rowstring += str(cell)
|
rowstring += str(cell)
|
||||||
elif cell == UNKNOWN or cell == MINE:
|
elif cell == UNKNOWN:
|
||||||
rowstring+= '#'
|
rowstring+= '#'
|
||||||
|
elif cell == MINE:
|
||||||
|
rowstring += 'X'
|
||||||
if selected:
|
if selected:
|
||||||
rowstring += ']|'
|
rowstring += ']|'
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user