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


Python Board.get_board方法代码示例

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


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

示例1: test_knock_tile

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import get_board [as 别名]
 def test_knock_tile(self):
     board = Board()
     board.move_checker('W', 1, 6)
     board.move_checker('B', 17, 1)
     #print(board.get_board())
     self.assertEqual(1, board.get_board()['W'][0])
     self.assertEqual(1, board.get_board()['B'][18])
开发者ID:rado992,项目名称:Python-Project,代码行数:9,代码来源:tests_board.py

示例2: test_move_tile

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import get_board [as 别名]
 def test_move_tile(self):
     board = Board()
     board.move_checker('W', 1, 3)
     self.assertEqual(1, board.get_board()['W'][4])
     self.assertEqual(1, board.get_board()['W'][1])
     board.move_checker('W', 1, 3)
     self.assertEqual(2, board.get_board()['W'][4])
     self.assertEqual(0, board.get_board()['W'][1])
开发者ID:rado992,项目名称:Python-Project,代码行数:10,代码来源:tests_board.py

示例3: test_takeout

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import get_board [as 别名]
 def test_takeout(self):
     board = Board(TAKEOUT_GAME)
     #print(board.get_board())
     board.move_checker('W', 19, 6)
     board.move_checker('W', 24, 1)
     self.assertEqual(False, board.move_checker('W', 24, 5))
     self.assertEqual(2, board.get_board()['W'][25])
     self.assertEqual(2, board.get_board()['W'][24])
     self.assertEqual(4, board.get_board()['W'][19])
开发者ID:rado992,项目名称:Python-Project,代码行数:11,代码来源:tests_board.py

示例4: LuckyPython

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import get_board [as 别名]
class LuckyPython(object):

    def __init__(self, conf={}):
        conf = self.get_conf_values()
        self.die = Die(no_of_faces=conf['no_of_faces_of_die'])
        self.board = Board(no_of_rows=conf['no_of_rows'],
                           no_of_columns=conf['no_of_columns'],
                           snakes_conf=conf['snakes'],
                           ladders_conf=conf['ladders'],
                           die=self.die)

    def get_board(self):
        return self.board.get_board()

    def get_changed_player(self):
        return self.board.get_active_player()

    def get_score(self):
        score = self.die.get_score()
        return score

    def add_player(self, object):
        return self.board.add_player(object)

    def set_board_status(self, object):
        if object['status'] == 'start':
            self.board.msg = 'Starting the game'
            self.board.status = 'P'  #start play

    def set_score(self, score_object):
        return self.board.set_score(score_object)

    def get_turn(self):
        return self.board.get_turn()

    def get_conf_values(self):
        """ get from user """ #FIXME
        conf_dict =  {'no_of_columns': 10,
                      'no_of_rows': 10,
                      'snakes': ((20, 10), (40, 6), (66, 33), (98, 18)),
                      'ladders': ((5, 14), (32, 62), (46, 58), (60, 84)),
                      'no_of_faces_of_die': 6}
        return conf_dict
开发者ID:spondbob,项目名称:progjar,代码行数:45,代码来源:lucky_python.py

示例5: Game

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import get_board [as 别名]
class Game(object):
    '''Class Game

    This class implements the game engine for game Isolation.
    '''

    def __init__(self):
	self.board = Board()
	self.cur_turn = 'p1'
	self.gameover = False
	self.winner = 'n/a'
	self.pc_first = True		# game engine goes first
	self.algo = alpha_beta_root     # assigning function pointer
	self.ui = Terminal(self.board)	# game UI is command line terminal!
	self.nom = 2 			# number of moves done on board
  
    def __get_direction(self, pos, move):
	'''Find the direction of move relative to pos.

	Return 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W' or 'NW'.
	'''

	if move[1]==pos[1] and move[0]<pos[0]: return 'N'
	if move[1]==pos[1] and move[0]>pos[0]: return 'S'
	if move[0]==pos[0] and move[1]<pos[1]: return 'W'
	if move[0]==pos[0] and move[1]>pos[1]: return 'E'
	if move[1]>pos[1] and (move[1]-pos[1])==(move[0]-pos[0]): return 'SE'
	if move[1]<pos[1] and (move[1]-pos[1])==(move[0]-pos[0]): return 'NW'
	if move[1]>pos[1] and (move[1]-pos[1])==(pos[0]-move[0]): return 'NE'
	if move[1]<pos[1] and (move[1]-pos[1])==(pos[0]-move[0]): return 'SW'

	# move is not in any of the 8 directions:
	return None

    def __is_blocked(self, drt, pos, move):
	'''Check if move is blocked by visited positions on board. 
	
	--- Function Arguments ---
	@drt: direction the move is in.
	@pos: the original position the pawn was at.
	@move: the move the pawn at pos try to make.
	@return: True if blocked, otherwise False.
	'''

	board = self.board.get_board()
	if drt == 'N':
	    for i in xrange(1, pos[0]-move[0]):
	    	if board[pos[0]-i][pos[1]]: return True
	elif drt == 'S':
	    for i in xrange(1, move[0]-pos[0]):
	    	if board[pos[0]+i][pos[1]]: return True
	elif drt == 'E':
	    for i in xrange(1, move[1]-pos[1]):
	    	if board[pos[0]][pos[1]+i]: return True
	elif drt == 'W':
	    for i in xrange(1, pos[1]-move[1]):
	    	if board[pos[0]][pos[1]-i]: return True
	elif drt == 'NE':
	    for i in xrange(1, move[1]-pos[1]):
	    	if board[pos[0]-i][pos[1]+i]: return True
	elif drt == 'NW':
	    for i in xrange(1, pos[1]-move[1]):
	    	if board[pos[0]-i][pos[1]-i]: return True
	elif drt == 'SE':
	    for i in xrange(1, move[1]-pos[1]):
	    	if board[pos[0]+i][pos[1]+i]: return True
	else:	# SW
	    for i in xrange(1, pos[1]-move[1]):
	    	if board[pos[0]+i][pos[1]-i]: return True
	return False

    def __set_gameover(self):
	"A helper function to set gameover and winner flag."
	
	self.gameover = True
    	self.winner = 'p1' if self.cur_turn=='p2' else'p2'

    def __set_search_depth(self):
	"A helper function to set search depth for alpha-beta algorithm."
	
	if self.nom <= 15: return 6
	elif self.nom <= 25: return 8
	elif self.nom <= 35: return 10
	elif self.nom <= 45: return 12
	elif self.nom <= 55: return 14
	else: return 10 
    
    def is_valid_move(self, move):
	'''Check if move is valid.

	Assume the format of move is sanitized by UI interface.

	--- Function Arguments ---
	@move: the move player in the current turn makes.
	@return: False if not a valid move, otherwise True.
	'''
    	
	# check entry validity
    	if not move[0] in xrange(self.board.size+1): return False
    	if not move[1] in xrange(self.board.size+1): return False
#.........这里部分代码省略.........
开发者ID:keenhenry,项目名称:pysolate,代码行数:103,代码来源:game.py

示例6: test_deep_copy

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import get_board [as 别名]
 def test_deep_copy(self):
     board1 = Board()
     board2 = copy.deepcopy(board1)
     board1.move_checker('W', 1, 1)
     self.assertNotEqual(board1.get_board(), board2.get_board())
开发者ID:rado992,项目名称:Python-Project,代码行数:7,代码来源:tests_board.py

示例7: test_new_board

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import get_board [as 别名]
 def test_new_board(self):
     board = Board()
     field = {}
     field['W'] = CLASSIC_GAME
     field['B'] = CLASSIC_GAME
     self.assertEqual(field, board.get_board())
开发者ID:rado992,项目名称:Python-Project,代码行数:8,代码来源:tests_board.py

示例8: Board

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import get_board [as 别名]
    bd.set_board(superset_board)
    matched_gems = bd.get_matched_gems()
elif use_one_match_board:
    bd = Board()
    bd.set_board(one_match_board)
    matched_gems = bd.get_matched_gems()
elif use_one_t_board:
    bd = Board()
    bd.set_board(one_t_board)
    matched_gems = bd.get_matched_gems()
else:
    # create board with default size 8x8
    num_gems_matched = 0
    while num_gems_matched < 20:
        bd = Board()
        matched_gems = bd.get_matched_gems()
        num_gems_matched = len(matched_gems)
    pprint(matched_gems)

raw_board = bd.get_board()
pprint(raw_board)
sparse_board = [[' ' for x in xrange(8)] for x in xrange(8)]
pprint(matched_gems)

for coord_pair in matched_gems:
    x_coord, y_coord = coord_pair
    sparse_board[y_coord][x_coord] = str(raw_board[y_coord][x_coord])

pprint(sparse_board)

bd.get_matches_t_l()
开发者ID:mplewis,项目名称:quantum_jewel,代码行数:33,代码来源:demo.py


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