本文整理汇总了Python中board.Board.board方法的典型用法代码示例。如果您正苦于以下问题:Python Board.board方法的具体用法?Python Board.board怎么用?Python Board.board使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board.board方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_check_win_vertical
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board [as 别名]
def test_check_win_vertical():
"""
Test for checking if connect 4 on vertical axis in corners (bounds)
"""
test_board = Board()
test_board.board = test_boards.VERTICAL_WIN_1
assert test_board.check_winner(1)
test_board.board = test_boards.VERTICAL_WIN_2
assert test_board.check_winner(2)
test_board.board = test_boards.VERTICAL_WIN_3
assert test_board.check_winner(1)
test_board.board = test_boards.VERTICAL_WIN_4
assert test_board.check_winner(2)
示例2: test_check_win_horizontal
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board [as 别名]
def test_check_win_horizontal():
"""
Test for checking if connect 4 on horizontal axis in corners (bounds)
"""
test_board = Board()
test_board.board = test_boards.HORIZONTAL_WIN_1
assert test_board.check_winner(1)
test_board.board = test_boards.HORIZONTAL_WIN_2
assert test_board.check_winner(2)
test_board.board = test_boards.HORIZONTAL_WIN_3
assert test_board.check_winner(1)
test_board.board = test_boards.HORIZONTAL_WIN_4
assert test_board.check_winner(2)
示例3: testBoardFromArray
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board [as 别名]
def testBoardFromArray(self):
arr = [[1,2,4,3],[0,0,2,3],[2,1,4,3],[2,3,4,9]]
b = Board()
b.board_from_array(arr)
prop = [[Square(1),Square(2),Square(4),Square(3)],
[Square(),Square(),Square(2),Square(3)],
[Square(2),Square(1),Square(4),Square(3)],
[Square(2),Square(3),Square(4),Square(9)]]
b2 = Board()
b2.board = prop
self.assertEqual(str(b), str(b2))
示例4: main
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board [as 别名]
def main():
# values of the snakes and ladders
snakes = [(16, 6), (48, 26), (49, 11), (56, 53), (62, 10), (64, 60), (87, 24), (93, 73), (95, 75), (98, 78)]
ladders = [(1, 38), (4, 14), (9, 31), (21, 42), (28, 84), (36, 44), (51, 67), (71, 91), (80, 100)]
board = Board()
board.board = 100
board.snakes = dict(snakes)
board.ladders = dict(ladders)
l = setOfGames(board, 1000, 6)
l_dictionary = {}
for i in l:
l_dictionary[i] = l_dictionary.get(i, 0) + 1
print l
average = getAverage(l)
print "Average: " + str(average)
print "Standard Deviation: " + str(getAverageStd(l, average))
示例5: td0_estimate_value
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board [as 别名]
V = td0_estimate_value(board_prototype, policy, nepisodes, alpha, gamma)
U = sorted(V.items(), key=lambda (a,b):b, reverse=True)
print 'Best Case\n {}'.format('\n'.join(map(str,U[0][0])))
print 'Worst Case\n {}'.format('\n'.join(map(str,U[-1][0])))
print len(V)
if __name__=='__main__' and action=='q':
board_prototype = Board(rows=3, cols=3, to_win=3) # board generator
print 'Learning values for RandomPolicy'
policy = RandomPolicy()
nepisodes = 10000
alpha = 0.05
gamma = 0.999
epsilon = 0.1
Q = q_learn(board_prototype, nepisodes, alpha, gamma, epsilon)
print len(Q)
#%%
board = Board(rows=3, cols=3, to_win=3)
board.board = np.array([
[2,0,0],
[2,0,2],
[1,0,1]
])
action = QGreedyPolicy(Q).take_action(board)
print 'Best action in \n{}\n --> {}'.format(board, action)
示例6: len
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import board [as 别名]
else:
#remain_size <= len(remain_data)
net_board_data += remain_data[:remain_size]
remain_data = remain_data[remain_size:]
remain_size = 0
#net_board_data done
#print (net_board_data)
dic = json.loads(net_board_data.decode())
#dic = pickle.loads(net_board_data)
#print('Got one dic-->\n', dic)
#print('-------------')
net_board_data = b''
tetris.board = dic['board']
#tetris.block = dic['block']
tetris.score = dic['score']
tetris.block.ref_pos = dic['ref_pos']
tetris.block.turn_type = dic['turn_type']
tetris.block.turn_delta = dic['turn_delta']
tetris.block.color_num = dic['color_num']
tetris.block.block_type = dic['block_type']
#print('dic : ref_pos -> ' ,dic['ref_pos'])
#print('dic : turn_type -> ', dic['turn_type'])
tetris.draw()
# tetris.draw()
elif remain_size < 0: