コード例 #1
0
def main(r, l, num):
	#allocate the game boards
	boardsList =  game.allocBoard(r, l);
	mineBoard = boardsList[0];
	statusBoard =  boardsList[1];
	
	#place the desired number of mines on a given mine board
	game.setMineNum(mineBoard, num);	

	print("Here is the minefield: ")
	gameio.displayBoard(mineBoard, statusBoard);
	
	#call the game-loop procedure
	re = gameio.gameLoop(mineBoard, statusBoard)
	if re==2 :
		print("You win the game. Congratuations!")
コード例 #2
0
def main(r, l, num):
    #allocate the game boards
    boardsList = game.allocBoard(r, l)
    mineBoard = boardsList[0]
    statusBoard = boardsList[1]

    #place the desired number of mines on a given mine board
    game.setMineNum(mineBoard, num)

    print("Here is the minefield: ")
    gameio.displayBoard(mineBoard, statusBoard)

    #call the game-loop procedure
    re = gameio.gameLoop(mineBoard, statusBoard)
    if re == 2:
        print("You win the game. Congratuations!")
コード例 #3
0
ファイル: level1.py プロジェクト: zhoulin487/blog_articles
import game
import gameio
import random

r, l, num = input("Enter a row, colunm and numbers of mines:\n").split()
r = int(r)
l = int(l)
num = int(num)
boardsList = game.allocBoard(r, l)
mineBoard = boardsList[0]
statusBoard = boardsList[1]
print("initial board: ")
gameio.displayBoard(mineBoard, statusBoard)

game.setMineNum(mineBoard, num)

#uncover half squares of the board in random.
print("start to uncover the square in random: ")
count = 0
over = 0
while count <= r * l / 2:
    row = random.randint(0, r - 1)
    col = random.randint(0, l - 1)
    if (statusBoard[row][col] == 0):
        statusBoard[row][col] = 1
        #game.setMatrixNum(mineBoard);
        count = count + 1
    print("after uncover an square (%d, %d):" % (row, col))
    gameio.displayBoard(mineBoard, statusBoard)
    if mineBoard[row][col] == -1:
コード例 #4
0
ファイル: level2.py プロジェクト: 123505653/blog_articles
import gameio
import random


r, l, num = input("Enter a row, colunm and numbers of mines:\n").split()
r = int(r)
l = int(l)
num = int(num)

boardsList = game.allocBoard(r, l)
mineBoard = boardsList[0]
statusBoard = boardsList[1]
print("initial board: ")
gameio.displayBoard(mineBoard, statusBoard)

game.setMineNum(mineBoard, num)

# uncover half squares of the board.
count = 0
over = 0
while count <= r * l / 2:
    row = random.randint(0, r - 1)
    col = random.randint(0, l - 1)
    if statusBoard[row][col] == 0:
        statusBoard[row][col] = 1
        count = count + 1
    print("after uncover an square (%d, %d):" % (row, col))
    gameio.displayBoard(mineBoard, statusBoard)
    if mineBoard[row][col] == -1:
        over = 1
        print("You have uncoverd a mine, game over!")