Example #1
0
def displayBoard(mineBoard, statusBoard):
	
	# display the mine board
	r = len(mineBoard);
	l = len(mineBoard[0])
	
	#place the number of adjacent mines in each square in a given mine board
	game.setMineBoardNum(mineBoard);
	
	i = 0;j =0;
	while i <= r:
		j = 0;
                
		while j <= l:
			if i== 0:
				if j==0:
					print("   ",end="")
				else:
					print(" %d " %(j-1),end="")
			elif j==0:
				print(" %d " %(i-1),end="")
			else:
				if statusBoard[i-1][j-1]==0:
					print("[-]",end="")
				elif mineBoard[i-1][j-1]!=-1:
					print("[%d]" %(mineBoard[i-1][j-1]),end="")
				else: 
					print("BOM",end="")	
			j = j + 1;

		print('\n');
		i = i + 1;
Example #2
0
def displayBoard(mineBoard, statusBoard):

    # display the mine board
    r = len(mineBoard)
    l = len(mineBoard[0])

    #place the number of adjacent mines in each square in a given mine board
    game.setMineBoardNum(mineBoard)

    i = 0
    j = 0
    while i <= r:
        j = 0

        while j <= l:
            if i == 0:
                if j == 0:
                    print("   ", end="")
                else:
                    print(" %d " % (j - 1), end="")
            elif j == 0:
                print(" %d " % (i - 1), end="")
            else:
                if statusBoard[i - 1][j - 1] == 0:
                    print("[-]", end="")
                elif mineBoard[i - 1][j - 1] != -1:
                    print("[%d]" % (mineBoard[i - 1][j - 1]), end="")
                else:
                    print("BOM", end="")
            j = j + 1

        print('\n')
        i = i + 1
Example #3
0
def displayBoomEachCol(mineBoard, statusBoard, col, boomFlag, bombFlag):
    r = len(mineBoard)
    l = len(mineBoard[0])

    #place the number of adjacent mines in each square in a given mine board
    game.setMineBoardNum(mineBoard)

    i = 0
    j = 0
    while i <= r:
        j = 0

        while j <= l:
            if i == 0:
                if j == 0:
                    print("   ", end="")
                else:
                    print(" %d " % (j - 1), end="")
            elif j == 0:
                print(" %d " % (i - 1), end="")
            else:
                if statusBoard[i - 1][j - 1] == 0:
                    if mineBoard[i - 1][j - 1] == -1:
                        if j - 1 == col:
                            print("%s" % (boomFlag), end="")
                        else:
                            print("%s" % (bombFlag), end="")
                    else:
                        print("[-]", end="")
                elif mineBoard[i - 1][j - 1] != -1:
                    print("[%d]" % (mineBoard[i - 1][j - 1]), end="")
                else:
                    print("BOM", end="")

            j = j + 1

        print('\n')
        i = i + 1
Example #4
0
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)

#test the 3rd function
print("calculates the number of mines adjacent to that location:")
row, col = input("Enter a row and colunm  of board:\n").split();
row = int(row);
col = int(col);
print("the number of mines adacent to (%d, %d) location: %d." %(row, col, game.getLocNum(mineBoard, row, col)))
print("\n")

#test the 4th function
game.setMineBoardNum(mineBoard);
print("place the number of adjacent mines in each square in a given mine board:")
displayBoard(mineBoard)

Example #5
0
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)

#test the 3rd function
print("calculates the number of mines adjacent to that location:")
row, col = input("Enter a row and colunm  of board:\n").split()
row = int(row)
col = int(col)
print("the number of mines adacent to (%d, %d) location: %d." %
      (row, col, game.getLocNum(mineBoard, row, col)))
print("\n")

#test the 4th function
game.setMineBoardNum(mineBoard)
print(
    "place the number of adjacent mines in each square in a given mine board:")
displayBoard(mineBoard)