예제 #1
0
def launch(width, height, bombs):
    """
    launch the game
    :param width: width of the game
    :type width: int
    :param height: height of the game
    :type height: int
    :param bombs: number of bombs
    :type bombs: int
    """
    game = ms.make_game(width, height, bombs)
    state = ms.get_state(game)
    while state == ms.GameState.unfinished:
        try:
            display_game(game)
            play(game)
            state = ms.get_state(game)
        except KeyboardInterrupt:
            sys.exit()
    display_game(game)
    if state == ms.GameState.losing:
        print("You lose!")
    elif state == ms.GameState.unfinished:
        print("You win!")
    else:
        print("an unexpected error has occured, please contact the developpers")
예제 #2
0
def launch(y,x,b):
    """
    launch a minesweeper game with a graphical board
    :param y: width of the game
    :type y: int
    :param x: height of the game
    :type x: int
    :param b: number of bombs
    :type b: int
    """
    game = ms.make_game(y,x,b)
    graphic.create(game)
예제 #3
0
import sys
import minesweeper as mines
import graphicalboard as graph

if __name__ == "__main__":
	assert len(sys.argv)==4, "Give me more arguments, please."
	assert (int(sys.argv[1])>0 and int(sys.argv[2])>0 and int(sys.argv[3])>0), "All these arguments should be positive."
	graph.create(mines.make_game(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3])))
예제 #4
0
import sys
import minesweeper as msp

if __name__ == "__main__":
    assert len(sys.argv)==4, "Give me more arguments, please."
    assert (int(sys.argv[1])>0 and int(sys.argv[2])>0 and int(sys.argv[3])>0), "All these arguments should be positive."
    g = msp.make_game(int(sys.argv[1]),int(sys.argv[2]),int(sys.argv[2]))
    while(msp.get_state(g)==msp.GameState(3)):
        msp.draw(g)
        tmp = input("Your play x,y,C (C=(R)eval,(S)et,(U)nset):")
        str = tmp.split(" ")
        print(str)
        if(str[2]=="R"):
            msp.reveal(msp.get_cell(g,int(str[0]),int(str[1])))
            continue
        if(str[2]=="S"):
            msp.set_hypothetic(msp.get_cell(g,int(str[0]),int(str[1])))
    if(get_state(g)==msp.GameState(1)):
        print("You won.")
    else:
        print("You lost.")
예제 #5
0
파일: graphical_main.py 프로젝트: veikn/S3
"""
:mod:`minesweeper` module : 

:author: `DECOTTIGNIES Cyril et MORLET Kevin`

:date: 2015, october
"""
import minesweeper as m
import graphicalboard as g
import sys

def usage ():
    print ('Usage : {:s} width height number_of_bombs'.format(sys.argv[0]))
    print ('with width the width of the minesweeper grid  ')
    print ('with height the height of the minesweeper grid ')
    print ('with number_of_bombs the number of bombs on the grid ')
    exit (1)

if len (sys.argv) ==0 :
     game=m.make_game()
     g.create(game)
elif len (sys.argv) == 4:
    width=int(sys.argv[1])
    height=int(sys.argv[2])
    nb_bombs=int(sys.argv[3])
    game=m.make_game(width,height,nb_bombs)
    g.create(game)
else :
    usage ()

예제 #6
0
파일: console_main.py 프로젝트: veikn/S3
:author: `DECOTTIGNIES Cyril et MORLET Kevin`

:date: 2015, october
"""
import minesweeper as m
import sys



def show_grid (game):
    for x in range(m.get_width(game)):
       print()
       for y in range(m.get_height(game)):
          cell=m.get_cell(game,x,y)
          if m.is_revealed(cell) :
             if m.is_bomb(cell):
                print ("B",end='')
             else : 
                print (m.number_of_bombs_in_neighborhood(cell),end='')
          else :  
             print(" ",end='')   
    print()


game=m.make_game(5,5,3)
show_grid(game)
while (m.get_state(game) == m.GameState.unfinished):
   val = input("Your play x,y,C (C=(R)eval,(S)et,(U)nset :")
   show_grid(game)