예제 #1
0
파일: engine.py 프로젝트: yangjiao2/Python
 def __init__(self, board, cols, rows, firstmove, topleft):      
     self._board = board
     self._cols = cols
     self._rows = rows
     self._turn = firstmove
     self._topleft = topleft
     self._logicboard = gamecode._get_new_board(self._turn, self._cols, self._rows, self._topleft)
예제 #2
0
파일: console.py 프로젝트: yangjiao2/Python
    def play_game():
        onemoretime = 'suppose_yes'
        while onemoretime:
            print(greeting)

            cols = _get_cols()
            rows = _get_rows()
            turn = _who_move_first()
            top_left_color = _which_color_on_top_left()
            board = gamecode._get_new_board(turn, cols, rows, top_left_color)
            game = Othello(turn, cols, rows, board)
            rule = _get_winning_rule()
            print('\nGame Starts!\n')

            Othello.take_turns(game)

            print('\nGame Ends!\n')

            winner = gamecode.choose_the_winner(game._turn, game._cols,
                                                game._rows, game._board, rule)
            print('The winner is(are): ' + winner + '\nCongratulations!')
            print('\nThanks for playing the game. Do you want to play again?')
            onemoretime = (input(
                'Press <ENTER> if you want to quit.\nOtherwise, press any key(s) on the keyboard.'
            ))
        print(ending)
예제 #3
0
 def __init__(self, board, cols, rows, firstmove, topleft):
     self._board = board
     self._cols = cols
     self._rows = rows
     self._turn = firstmove
     self._topleft = topleft
     self._logicboard = gamecode._get_new_board(self._turn, self._cols,
                                                self._rows, self._topleft)
예제 #4
0
    def play_game():
        onemoretime = 'suppose_yes'
        while onemoretime:
            print (greeting)
            
            cols = _get_cols()
            rows = _get_rows()
            turn = _who_move_first()
            top_left_color =  _which_color_on_top_left()
            board = gamecode._get_new_board(turn, cols, rows, top_left_color)
            game = Othello(turn, cols, rows, board)
            rule = _get_winning_rule()
            print ('\nGame Starts!\n')
            
            Othello.take_turns(game)

            print ('\nGame Ends!\n')
            
            winner = gamecode.choose_the_winner(game._turn, game._cols, game._rows, game._board, rule)
            print ('The winner is(are): '+ winner + '\nCongratulations!')
            print ('\nThanks for playing the game. Do you want to play again?')
            onemoretime = (input('Press <ENTER> if you want to quit.\nOtherwise, press any key(s) on the keyboard.'))
        print (ending)