Esempio n. 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!")
Esempio n. 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!")
Esempio n. 3
0
#!/usr/bin/env python

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)
Esempio n. 4
0
#!/usr/bin/env python

import game
import gameio

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

game.uncoverLoc(mineBoard, statusBoard, 2, 2);
print("uncovering Loction(2,2):")
gameio.displayBoard(mineBoard, statusBoard);


Esempio n. 5
0
                        elif j==0:
                                print(" %d " %(i-1),end="")
                        else:
                                print("[%d]" %(board[i-1][j-1]),end="")
                        j = j + 1;

                print('\n');
                i = i + 1;


#test the 1st function
row,col,num = input("Enter a row, colunm and numbers of mines:\n").split();
row = int(row)
col = int(col)
num = int(num)
boardsList =  game.allocBoard(int(row), int(col));
mineBoard = boardsList[0]
statusBoard = boardsList[1];


#test the 5th funciton
print("initialize the given status board:")
game.initStatusBoard(statusBoard);
displayBoard(statusBoard)

print("initial mine board: ")
displayBoard(mineBoard)

#test the 2nd function
game.setMineNum(mineBoard, num);
print("place the desired number of mines:")
Esempio n. 6
0
            elif j == 0:
                print(" %d " % (i - 1), end="")
            else:
                print("[%d]" % (board[i - 1][j - 1]), end="")
            j = j + 1

        print('\n')
        i = i + 1


#test the 1st function
row, col, num = input("Enter a row, colunm and numbers of mines:\n").split()
row = int(row)
col = int(col)
num = int(num)
boardsList = game.allocBoard(int(row), int(col))
mineBoard = boardsList[0]
statusBoard = boardsList[1]

#test the 5th funciton
print("initialize the given status board:")
game.initStatusBoard(statusBoard)
displayBoard(statusBoard)

print("initial mine board: ")
displayBoard(mineBoard)

#test the 2nd function
game.setMineNum(mineBoard, num)
print("place the desired number of mines:")
displayBoard(mineBoard)