From 82b97c3247d9e60b50828167a84f8ec1690ecd52 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Apr 2018 09:56:09 +0200 Subject: [PATCH] fixed x-y mishap --- minebash.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) mode change 100644 => 100755 minebash.py diff --git a/minebash.py b/minebash.py old mode 100644 new mode 100755 index 08e9865..88c924c --- a/minebash.py +++ b/minebash.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2 import readline, random, io, sys import curses @@ -33,12 +33,12 @@ def setup_strings(colcount): def calculate_hint(col, row): hint = 0 - if playfield[col][row] != MINE: + if playfield[row][col] != MINE: for x in range(col-1, col+2): if x >= 0 and x < len(playfield)-1: for y in range(row-1, row+2): if y >= 0 and y < len(playfield[0])-1: - if(playfield[x][y] == MINE): + if(playfield[y][x] == MINE): hint+=1 else: hint = MINE @@ -81,8 +81,10 @@ def print_playfield(playfield): # did we find a hint? if cell >= 0: rowstring += str(cell) - elif cell == UNKNOWN or cell == MINE: - rowstring+='#' + elif cell == UNKNOWN: + rowstring+= '#' + elif cell == MINE: + rowstring += 'X' if selected: rowstring += ']|' else: @@ -142,4 +144,4 @@ if __name__ == "__main__": curses.nocbreak() stdscr.keypad(False) curses.echo() - curses.endwin() \ No newline at end of file + curses.endwin()