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


Python Board.board方法代码示例

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


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

示例1: main

# 需要导入模块: import Board [as 别名]
# 或者: from Board import board [as 别名]
def main():
	
	numPlayers = -1
	#test Ben
	#sublime text can't work with stdin, so hardcoded it as a 2 player game while on sublime
	while(True):
		try:
			response = raw_input('How many players do you want? ')
			numPlayers = int(response)
		except ValueError:
			print "Please enter a number"
			continue
		if (numPlayers >= 0 and numPlayers <= 4):
			break
		else:
			print "Please enter a number betweeen 0 and 4"
	players = []
	for i in range (0, numPlayers):
		players.append(Player.player(i))
	AiNum = -1
	try:
            response = raw_input("Add an Ai player?")
            if response == "Yes" or response == "yes" or response == "y":
                AiNum = len(players)			
                players.append(Ai.ai(AiNum))
                numPlayers +=1
	except EOFError:
		print " Not building, on sublime"
        if AiNum != -1 and numPlayers == 1:
	   numRuns = input('How many runs? ')
	else:
	   numRuns = 1
	if numRuns > 1:
	        stats = []
           	for x in xrange(numRuns):
           	    numPlayers = 1
           	    players = []
           	    AiNum = len(players)			
                    players.append(Ai.ai(AiNum))
                    board = Board.board()
               	    devCardsDeck = Devcards.devcards()
                    #board.createBatchCSV(players)
                    #board.batchUpdate()
                    #print board.printBoard()
                    firstPlacement(numPlayers, players, board, AiNum)
                    stats.append(playMainGame(numPlayers, players, board, devCardsDeck, AiNum))
                print stats
                print "average turns (excluding robber) = ", sum(stats)/float(numRuns)
        else:
            board = Board.board()
            devCardsDeck = Devcards.devcards()
            board.createBatchCSV(players)
            board.batchUpdate()
            print board.printBoard()
            firstPlacement(numPlayers, players, board, AiNum)
            playMainGame(numPlayers, players, board, devCardsDeck, AiNum)
开发者ID:ulmerb,项目名称:CatanBackend,代码行数:58,代码来源:Controller.py

示例2: tileInitialization

# 需要导入模块: import Board [as 别名]
# 或者: from Board import board [as 别名]
def tileInitialization(numPlayers, ai):
	board = Board.board()
	devCardsDeck = Devcards.devcards()
	players = []
	for i in range (0, numPlayers):
		players.append(Player.player(i))
	AiNum = -1
	if ai:
		players.append(Ai.ai(len(players)))
		players[-1].verbose = True
		numPlayers +=1
	if not ai or numPlayers > 1:
	   board.createBatchCSV(players)
	   board.batchUpdate()
	return board, players
开发者ID:ulmerb,项目名称:CatanBackend,代码行数:17,代码来源:Controller.py

示例3: TicTacToeBoard

# 需要导入模块: import Board [as 别名]
# 或者: from Board import board [as 别名]
check whether the player is win or not in Tic Tac Toe game
'''
import Board

class TicTacToeBoard(Board):
  def __init__(self):
    super(TicTacToeBoard,self)__init__(
        num_rows=3, num_cols=3, init_char=' ')
    # self.n = 3
    # self.board = [['','',''] for i in range(3)]

  def HasWon(self, player):
    """Whether the given 'player' has won."""
    # check all the items in each row
    for row in self.board:
      if all(item == player for item in row):
        return True
    # check all the items in each column
    for c in range(self.n):
      if all(self.board[r][c] == player for r in range(self.n)):
        return True
    # check the '/'-style diagonal
    if all(self.board[i][i] == player for i in range(self.n)):
      return True
    # check the '\'-style diagonal
    if all(self.board[i][self.n -1 - i] == player for i in range(self.n)):
      return True   

b = Board()
b.board = [['x','x','x'],['x','o','x'],['x','x','o']]
print b.HasWon('x')
开发者ID:ebaumstarck,项目名称:PythonProblemSolving,代码行数:33,代码来源:TicTacToe.py

示例4: __init__

# 需要导入模块: import Board [as 别名]
# 或者: from Board import board [as 别名]
import Players as p
import Board 
import minimax
game = Board.board([0,0,0,0,0,0,0,0,0],None,p.Players.CROSS)
class TextInterface:

    def __init__(self):
        print"set"

    def gameLoop(self):
        global Board
        global game
        print "How would you like to play?"
        print "press 1 for p vs p \n press 2 for p vs c >>"
        answer = raw_input()
        if(answer == '1'):
            print "answer was 1"
            while(True):
                TextInterface.playerMove(self)
                game.printBoard()
                if (game.winner() is not p.Players.NONE):
                    break
        if(answer == '2'):
            print "answer was 2"
            while(True):
                TextInterface.playerMove(self)
                game.printBoard()
                if(game.winner() is not p.Players.NONE):
                    break
                TextInterface.computerMove(self)
开发者ID:inge91,项目名称:Python-code,代码行数:32,代码来源:TextInterface.py


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