当前位置: 首页>>代码示例>>Python>>正文


Python Board.start方法代码示例

本文整理汇总了Python中board.Board.start方法的典型用法代码示例。如果您正苦于以下问题:Python Board.start方法的具体用法?Python Board.start怎么用?Python Board.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在board.Board的用法示例。


在下文中一共展示了Board.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Tetris

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import start [as 别名]
class Tetris(QMainWindow):

    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):

        self.tboard = Board(self)
        self.setCentralWidget(self.tboard)

        self.statusbar = self.statusBar()
        self.tboard.msg2Statusbar[str].connect(self.statusbar.showMessage)

        self.tboard.start()

        self.resize(180, 380)
        self.center()
        self.setWindowTitle('Tetris')
        self.show()

    def center(self):

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)
开发者ID:alixbreed,项目名称:tetris,代码行数:30,代码来源:tetris.py

示例2: Tetris

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import start [as 别名]
class Tetris(QtGui.QMainWindow):
	def __init__(self):
		QtGui.QMainWindow.__init__(self)

		self.setGeometry(300, 300, 180, 380)
		self.setWindowTitle('Tetris')
		self.tetrisboard = Board(self)

		self.setCentralWidget(self.tetrisboard)

		self.statusbar = self.statusBar()
		self.connect(self.tetrisboard, QtCore.SIGNAL("messageToStatusbar(QString)"), self.statusbar, QtCore.SLOT("showMessage(QString)"))
		self.tetrisboard.start()
		self.center()

	def center(self):
		screen = QtGui.QDesktopWidget().screenGeometry()
		size = self.geometry()
		self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
开发者ID:lsn12114,项目名称:Tetris,代码行数:21,代码来源:tetris.py

示例3: Exception

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import start [as 别名]
     # Key down handling specific to menu state
     elif game_state == "menu":
       # Move down in menu
       if event.key == pygame.K_DOWN:
         menu_obj.menu_down()
       # Move up in menu
       elif event.key == pygame.K_UP:
         menu_obj.menu_up()
       # Execute selected menu item
       elif event.key == pygame.K_RETURN:
         # Play game
         if menu_obj.selected == "Play":
           # Change program state to play mode
           game_state = "play"
           # Start game
           game_board.start()
         # Exit game
         elif menu_obj.selected == "Exit":
           sys.exit()
         else:
           raise Exception("Unknown menu item.")
         
     else:
       raise Exception("Unknown game state.")            
     
 elif event.type == pygame.KEYUP:
   # Key up handling when in play state
   if game_state == "play":
     # Decrease fall speed once DOWN is released
     if event.key == pygame.K_DOWN:
       game_board.slow_down()
开发者ID:dlowashere,项目名称:Something-Something-Bricks,代码行数:33,代码来源:ssb.py

示例4: Dice

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import start [as 别名]
dice3 = Dice(3)
assert dice3.roll() in ['A','B','J','M','O','Qu'], "Return should be in ['A','B','J','M','O','Qu']."

value = dice3.value
assert value in ['A','B','J','M','O','Qu'], "Return should be in ['A','B','J','M','O','Qu']."
#assert dice3 == value, '"value" has same value of "dice3.value", should return True.'


### Board tests ###
from board import Board

board = Board()
assert type(board.board) == list, "Board should be type list."
assert len(board.board) == 0, "Board should be clean when initiated."

board.start()
assert len(board.board) == 4, "After calling start board should have 4 rows."
assert len(board.board[0]) == 4, "After calling start should have 4 columns in each row."
assert type(board.board[0][0]) == Dice, "Every item in every row of the board should be type Dice, an instance of Dice class."

board.clear()
assert len(board.board) == 0, "Board should be empty after calling clean()."

board.start()
assert type(board.get_item(1,2)) == Dice, "Should return the the 3rd item from the second row, an Dice object"

assert len(board.get_surrounds(3,3)) == 3, "Should return a list with 3 Dices, the surrounds of the dice on 4th row and 4th column."
assert len(board.get_surrounds(1,1)) == 8, "Should return a list with 8 Dices, the surrounds of the dice on 2nd row and 2nd column."
assert len(board.get_surrounds(0,2)) == 5, "Should return a list with 5 Dices, the surrounds of the dice on 1st row and 3rd column."

开发者ID:profiteers-2015,项目名称:weekend2_boggle,代码行数:31,代码来源:tests.py

示例5: Board

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import start [as 别名]
from board import Board
from copy import deepcopy
import random
import math
trim_limit = 3

b = Board(height=10, width=5)

b.start()
number_of_board_states = 7 ** b.width

piece_array = []
# Calculate the rotation map
for piece in b.pieces:
    for i in range(4):
        piece = deepcopy(piece)
        if piece not in piece_array:
            piece_array.append(piece)
        piece = b.rotatePiece(deepcopy(piece))
available_actions = [ 'w', 'a', 's', 'd' ]

class QLearner:
    points_at_last_check = 0
    death_punishment = -5.0
    inactivity_punishment = -1.0
    learning_rate = 1.0
    discount_factor = 0.99
    q_values = [[[[0 for action in range(len(available_actions))] for column in range(b.width)] for piece_type in range(len(piece_array))] for board_state in range(number_of_board_states)]

    def encode_board(self, board):
        total = 0
开发者ID:seb5666,项目名称:tetris-ai,代码行数:33,代码来源:q-learner.py

示例6: Game

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import start [as 别名]
class Game(QtGui.QMainWindow):
    
    ## Constructor, initializes UI
    def __init__(self):
        super(Game, self).__init__()
        self.initUI()
    
    ## This method initializes the UI and center the window
    def initUI(self):    

        self.centralWidget = QtGui.QStackedWidget()
        self.setCentralWidget(self.centralWidget)

        self.showLoginMenu()

    ## This method displays the login menu
    def showLoginMenu(self):

        self.loginWidget = LoginMenu(self)

        self.loginWidget.loginSuccessSignal.connect(self.showMainMenu)

        self.centralWidget.addWidget(self.loginWidget)
        self.centralWidget.setCurrentWidget(self.loginWidget)

        self.setWindowTitle('Login')
        self.center()

    ## This method displays the login menu after successful login
    def showMainMenu(self):

        self.username = self.loginWidget.loggedUsername

        self.mainMenuWidget = MainMenu(self)

        self.mainMenuWidget.playGameSignal.connect(self.showLevelMenu)
        self.mainMenuWidget.logoutGameSignal.connect(self.showLoginMenu)
        self.mainMenuWidget.quitGameSignal.connect(self.quit)
        self.mainMenuWidget.showLeaderboardSignal.connect(self.showLeaderboard)
        self.mainMenuWidget.loadMenuSignal.connect(self.showLoadMenu)
        self.mainMenuWidget.changeSettingsSignal.connect(self.showAccountSettingsMenu)

        self.centralWidget.addWidget(self.mainMenuWidget)
        self.centralWidget.setCurrentWidget(self.mainMenuWidget)

        self.setWindowTitle('Main Menu')
        self.center()

    ## This method displays the level menu where player is asked to select level to play
    def showLevelMenu(self):

        self.levelMenuWidget = LevelMenu(self, self.username)

        self.levelMenuWidget.backToMainMenuSignal.connect(self.showMainMenu)
        self.levelMenuWidget.startLevelSignal.connect(self.showBoard)

        self.centralWidget.addWidget(self.levelMenuWidget)
        self.centralWidget.setCurrentWidget(self.levelMenuWidget)

        self.setWindowTitle('Choose Level')
        self.center()

    ## This method displays the bomberman gameplay and initiliazes the game to the selected level
    # @param levelNum: Integer the level number
    # @param level: Level object containing all the information necessary to run the game
    def showBoard(self, levelNum, level=None):

        if not level:
            level = Level(self.username,levelNum)
        
        self.board_widget = Board(level, self)

        self.board_widget.pauseGameSignal.connect(self.showPauseMenu)
        self.board_widget.gameOverSignal.connect(self.gameOver)
        self.board_widget.updateScoreInDbSignal.connect(self.updateScoreInDb)

        self.centralWidget.addWidget(self.board_widget)
        self.centralWidget.setCurrentWidget(self.board_widget)

        self.board_widget.start()

        self.resize(468, 468)
        self.setWindowTitle('Bomberman')

    ## This method isplays the leaderboard
    def showLeaderboard(self, previousMenu):

        self.leaderboardWidget = Leaderboard(self, previousMenu)

        if previousMenu == constant.MAIN_MENU:
            self.leaderboardWidget.backSignal.connect(self.showMainMenu)
        elif previousMenu == constant.PAUSE_MENU:
            self.leaderboardWidget.backSignal.connect(self.showPauseMenu)

        self.centralWidget.addWidget(self.leaderboardWidget)
        self.centralWidget.setCurrentWidget(self.leaderboardWidget)

        self.setWindowTitle('Leaderboard')
        self.center()

#.........这里部分代码省略.........
开发者ID:michaelchum,项目名称:bomberman-py,代码行数:103,代码来源:game.py


注:本文中的board.Board.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。