Example #1
0
            window.refresh()
            time.sleep(0.5)

    # If manual toggled...
    if (event == '-manual-'):
        is_manual = True
        window['-step-'].update(disabled=is_manual,
                                button_color=('white', 'gray'))

    if (is_manual and 'tile' in event):
        if(not is_initialized):
            minesweeper.initialize_board()
            is_initialized = True
        else:
            r, c = list(map(int, event.split('_')[1:]))
            minesweeper.reveal((r, c))

    # If manual is not toggled and
    if (event == '-step-' and not is_manual):
        if(not is_initialized):
            minesweeper.initialize_board()
            is_initialized = True
        else:
            minesweeper.inference()

    update_gui()

    # If the minesweeper state is Terminal State
    if (minesweeper.status == MinesweeperStatus.LOSE):
        gui.popup(lose_message[random.randint(
            0, len(lose_message) - 1)], title='You lose!')
Example #2
0
 def test_command_mass_reveal_position(self):
     minesweeper = Minesweeper()
     minesweeper.new_game()
     minesweeper.reveal({'row': 0, 'col': 0})
     minesweeper.mass_reveal({'row': 0, 'col': 0})