def start_menu_choice(choice): global game game = minesweeper(int(choice)) game.generate_random_mines() game_screen.show(game.get_boxes(), game.level) with keyboard.Listener(on_press=on_game_press) as game_listener: game_listener.join()
class minesweeper_test(unittest.TestCase): form = minesweeper() def testingGUI(self): self.assertEqual(self.form.board_size, 10) def testing_mines(self): self.assertEqual(self.form.num_mines, 10) def testing_grid(self): for x in range(0, self.form.board_size): for y in range(0, self.form.board_size): tile = self.form.grid.itemAtPosition(y, x).widget() self.assertEqual(tile.revealed, False) def testing_flags(self): for x in range(0, self.form.board_size): for y in range(0, self.form.board_size): tile = self.form.grid.itemAtPosition(y, x).widget() self.assertEqual(tile.flagged, False) def testing_reset(self): self.assertEqual(self.form.button.text(), "Reset") def testing_clock(self): self.assertEqual(self.form.timer_start_secs, int(time.time())) def testing_mines_count(self): self.assertEqual(self.form.mines.text(), '10')
def index(): global game game = minesweeper.minesweeper(int(request.form.get('len')), float(request.form.get('lvl'))) game.setupMines() return render_template('index.html', title='Home', fmatrix=game.frontmatrix, bmatrix=game.backmatrix)
def generate_Solve(width, height, mines): board = minesweeper.minesweeper(width, height, mines) board.reveal(0, 0) #start from corner #board.reveal(width / 2, 0) #start from edge #board.reveal(width / 2, height / 2) #start from centre #board.showBoard() while(not board.won() and not board.lost()): #board.showBoard() changed = detectTrivial(board) if changed == 0: randomReveal(board) return board
async def on_message(message): global connect4Msg global connect4 if message.author == client.user: if connect4 and len(message.content) > 117: connect4Msg = message return #automatically respond to "yeah but"s elif "yeah but" in message.content.lower().replace(",", ""): await message.channel.send("Yeahbuts live in the woods.") spendDiscordDollars(message.author.id, 50) #start a connect four game elif message.content.startswith('CONNECT FOUR'): global connect4arr global connect4TwoPlayers global connect4player1 if connect4 == False: connect4arr = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7]] connect4 = True connect4TwoPlayers = False connect4player1 = message.author.id await connectfour(message, 0) #play connect 4 move (1-7) if a game is already underway elif message.content.isnumeric() and 0 < int(message.content) < 8: if connect4: if message.author.id != connect4player1: connect4TwoPlayers = True await connectfour(message, int(message.content)) return #generate minesweeper board elif message.content.startswith('MINESWEEPER'): await message.channel.send(minesweeper()) #pull garflied comic from Garflied archive elif message.content.startswith('GARFIELD PLEASE'): await message.channel.send(getGarfield()) spendDiscordDollars(message.author.id, 5) #random Dilbert strip elif message.content.startswith('DILBERT PLEASE'): await message.channel.send(getDilbert()) spendDiscordDollars(message.author.id, 5) #random C&H elif message.content.startswith('CALVIN AND HOBBES PLEASE'): await message.channel.send(getGoComic("calvinandhobbes")) #respond to @s elif client.user.mentioned_in(message): await message.channel.send('Hi!') #add one to DiscordDollar count just for sending a message, process other commands addDiscordDollars(message.author.id, 1) await client.process_commands(message)
import clips import logging from minesweeper import minesweeper # input size of board and number of bombs size = int(input()) n = int(input()) bombs = [] for i in range(n): x, y = map(int, input().split(',')) bombs.append((x, y)) env = clips.Environment() game = minesweeper(size, bombs) env.load("./minesweeper.clp") # Masukin fact size + jumlah bomb s = "(defglobal MAIN $*size* " + str(size) + ")" env.assert_string(s) s = "(defglobal MAIN $*bomb-count* " + str(n) + ")" env.assert_string(s) # Masukin fact posisi for i in range(size): for j in range(size): s = "(position (x " + str(i) + ") (y " + str(j) + "))" env.assert_string(s)