本文整理汇总了Python中board.Board.to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Board.to_string方法的具体用法?Python Board.to_string怎么用?Python Board.to_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board.to_string方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_moves7
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_moves7():
moves = ['d4', 'Nf6', 'c4', 'c5', 'd5', 'b5', 'cxb5', 'a6', 'e3', 'Bb7', 'Nc3', 'axb5', 'Bxb5', 'Qa5', 'Bd2', 'Qb6', 'Nf3', 'Nxd5', 'Nxd5', 'Bxd5', 'a4', 'e6', 'Bc3', 'Be7', 'O-O', 'O-O', 'Ne5', 'd6', 'Nc4', 'Bxc4', 'Qg4', 'g6', 'Qxc4', 'Nc6', 'e4', 'Nd4', 'Bxd4', 'cxd4', 'Rfc1', 'Bg5', 'Rc2', 'Kg7', 'b4', 'Rfc8', 'Qxc8', 'Rxc8', 'Rxc8', 'd3', 'Bxd3', 'Qd4', 'Rd1', 'Qxb4', 'Bc2', 'Bf6', 'h3', 'Bd4', 'Rf1', 'Bc5', 'Ra8', 'h5', 'a5', 'Qb7', 'Re8', 'Qa6', 'Bd1', 'Qxa5', 'Bf3', 'h4', 'Re7', 'Qb4', 'Rc7', 'Qb6', 'Rc8', 'Qb7', 'Re8', 'Qb2', 'Bd1', 'Qd2', 'Bf3', 'Qd4', 'Ra8', 'Kf6', 'Ra2', 'Qe5', 'Rc1', 'Qf4', 'Rc4', 'Ke5', 'Re2', 'Qg5', 'Kf1', 'Qd8', 'Rcc2', 'Qa5', 'Ra2', 'Qc3', 'Rac2', 'Qd3', 'Kg1', 'Qd1+', 'Kh2', 'Qa1', 'Ra2', 'Qc3', 'Rec2', 'Qd4', 'Rd2', 'Qc3', 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1', 'Rd8+', 'Ke3']
b = Board()
for move in moves:
b.move_algebraic(move)
assert b.to_string() == \
" r P k PK Q "
示例2: test_moves6
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_moves6():
moves = ['d4', 'Nf6', 'c4', 'c5', 'd5', 'b5', 'Nf3', 'b4', 'Nbd2', 'g6', 'b3', 'Bg7', 'Bb2', 'O-O', 'e4', 'd6', 'Qc2', 'e5', 'dxe6', 'Bxe6', 'g3', 'Nc6', 'Bg2', 'Bg4', 'O-O', 'Nd7', 'h3', 'Bxf3', 'Nxf3', 'Bxb2', 'Qxb2', 'Nde5', 'Ne1', 'Nd4', 'f4', 'Nec6', 'Nd3', 'a5', 'Rad1', 'a4', 'Kh2', 'axb3', 'axb3', 'Ra3', 'Nc1', 'Qf6', 'Rf2', 'Rfa8', 'Re1', 'Qe7', 'Re3', 'Ra1', 'e5', 'dxe5', 'Nd3', 'R8a2', 'Qxa2', 'Rxa2', 'Rxa2', 'Nf5', 'Re1', 'Qd6', 'Bd5', 'exf4', 'Nxf4', 'h5', 'h4', 'Nce7', 'Rd2', 'Kg7', 'Rd3', 'Nxg3', 'Rxe7', 'Nf1+', 'Kg2', 'Qxe7', 'Kxf1', 'Qxh4', 'Rf3', 'Qh1+', 'Ke2', 'Qb1', 'Nxh5+', 'gxh5', 'Rxf7+', 'Kh6', 'Rf3', 'Qg1', 'Rf6+', 'Kg5', 'Rf2', 'Qb1', 'Rf3', 'Qc2+', 'Ke1', 'Kg4', 'Re3', 'h4', 'Bb7', 'Qh2', 'Kf1', 'Qd2', 'Bc8+', 'Kf4', 'Rh3', 'Qd8', 'Bb7', 'Qd1+', 'Kf2', 'Qc2+', 'Kf1', 'Qd1+', 'Kf2', 'Qd2+', 'Kf1', 'Ke5', 'Bg2', 'Qg5', 'Kf2', 'Kd4', 'Rf3', 'Qc1', 'Bh3', 'Qd2+', 'Kf1', 'Qd1+', 'Kf2', 'Qh1', 'Bg2', 'Qc1', 'Bh3', 'Qb2+', 'Kf1', 'Qc3', 'Kf2', 'Qd2+', 'Kf1', 'Ke4', 'Bg2', 'Ke5', 'Bh3', 'Kd4', 'Bg2', 'Qa2', 'Bh3', 'Qh2', 'Bg2', 'Qe5', 'Kf2', 'Qe4', 'Bh3', 'Qc2+', 'Kf1', 'Qd2', 'Bg2', 'Qc1+', 'Kf2', 'Qb2+', 'Kf1', 'Qa1+', 'Kf2', 'Ke4', 'Rh3+', 'Kf5', 'Rf3+', 'Kg5', 'Bh3', 'Qb2+', 'Kf1', 'Qc2', 'Ke1', 'Qe4+', 'Kf2', 'Qb1', 'Kg2', 'Qe1', 'Rf5+', 'Kg6', 'Rf3', 'Kg7', 'Rf2', 'Qd1', 'Rf3', 'Qd2+', 'Kf1', 'Kg6', 'Bg2', 'Qd1+', 'Kf2', 'Qd4+', 'Kf1', 'Qg4', 'Kf2', 'Kg5', 'Bh3', 'Qe4', 'Kg2', 'Qe2+', 'Rf2']
b = Board()
for move in moves:
b.move_algebraic(move)
assert b.to_string() == \
" P K Pp P p b Qrk "
示例3: test_moves5
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_moves5():
moves = ['e4', 'e5', 'Nf3', 'Nc6', 'Bb5', 'a6', 'Ba4', 'Nf6', 'O-O', 'Be7', 'Re1', 'b5', 'Bb3', 'd6', 'c3', 'O-O', 'h3', 'Nb8', 'd4', 'Nbd7', 'c4', 'c6', 'cxb5', 'axb5', 'Nc3', 'Bb7', 'Bg5', 'b4', 'Nb1', 'h6', 'Bh4', 'c5', 'dxe5', 'Nxe4', 'Bxe7', 'Qxe7', 'exd6', 'Qf6', 'Nbd2', 'Nxd6', 'Nc4', 'Nxc4', 'Bxc4', 'Nb6', 'Ne5', 'Rae8', 'Bxf7+', 'Rxf7', 'Nxf7', 'Rxe1+', 'Qxe1', 'Kxf7', 'Qe3', 'Qg5', 'Qxg5', 'hxg5', 'b3', 'Ke6', 'a3', 'Kd6', 'axb4', 'cxb4', 'Ra5', 'Nd5', 'f3', 'Bc8', 'Kf2', 'Bf5', 'Ra7', 'g6', 'Ra6+', 'Kc5', 'Ke1', 'Nf4', 'g3', 'Nxh3', 'Kd2', 'Kb5', 'Rd6', 'Kc5', 'Ra6', 'Nf2', 'g4', 'Bd3', 'Re6']
b = Board()
for move in moves:
b.move_algebraic(move)
assert b.to_string() == \
" r P K P P p p B p k N "
示例4: test_moves2
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_moves2():
b = Board()
b.move_algebraic("e4")
b.move_algebraic("e5")
b.move_algebraic("Nf3")
b.move_algebraic("Nc6")
b.move_algebraic("Bb5")
b.move_algebraic("a6")
b.move_algebraic("Bxc6")
assert b.to_string() == \
"R BQKBNR PPP PPPP b P p n pppp ppprnbqk r"
示例5: test_sucessors_for_the_default_board
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_sucessors_for_the_default_board(self):
board = Board(6, 4)
board.initialize_default_board()
player_one = Player(Player.IDIOT, Piece.BLACK)
player_two = Player(Player.IDIOT, Piece.WHITE)
game = Game(player_one, player_two)
board_copy = copy.deepcopy(board)
self.assertEqual(board.to_string(), board_copy.to_string())
示例6: test_moves4
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_moves4():
b = Board()
b.move_algebraic("e4")
b.move_algebraic("e5")
b.move_algebraic("Nf3")
b.move_algebraic("Nc6")
b.move_algebraic("Bb5")
b.move_algebraic("a6")
b.move_algebraic("Bxc6")
b.move_algebraic("dxc6")
b.move_algebraic("d3")
b.move_algebraic("Bb4+")
b.move_algebraic("Nc3")
b.move_algebraic("Nf6")
b.move_algebraic("O-O")
b.move_algebraic("Bxc3")
b.move_algebraic("Re1")
assert b.to_string() == \
"R BQK R PP PPPP P N P p Bp n ppp pppr bqr k "
示例7: test_sucessors_for_a_little_board_with_a_few_pieces
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_sucessors_for_a_little_board_with_a_few_pieces(self):
board = Board(3, 2)
b_king = Piece(Piece.KING, Piece.BLACK)
b_queen = Piece(Piece.QUEEN, Piece.BLACK)
w_king = Piece(Piece.KING, Piece.WHITE)
w_queen = Piece(Piece.QUEEN, Piece.WHITE)
board.add(b_queen, 0, 0)
board.add(b_king, 0, 1)
board.add(w_queen, 2, 1)
board.add(w_king, 2, 0)
player_one = Player(Player.IDIOT, Piece.WHITE)
player_two = Player(Player.HUMAN, Piece.BLACK)
game = Game(player_one, player_two)
board_copy = copy.deepcopy(board)
# print game.successors(board)
self.assertEqual(board.to_string(), board_copy.to_string())
示例8: __init__
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
class MySolver:
""" This class should contain the movement generation algorythm."""
def __init__(self):
self._direction = None
self._board = None
def get(self, board_string):
""" The function that should be implemented."""
self._board = Board(board_string)
_command = self.find_answer()
print("Sending command {}".format(_command))
return _command
def find_answer(self):
""" This is an example of the solver subroutine."""
if self._board.is_bankrupt():
print("Bankrupt. Sending reset command...")
return "message('go reset')"
if self._board.is_gameover():
print("Game Over. Sending reset command...")
return "message('go reset')"
# print(self._board.day())
# print(self._board.is_bankrupt())
# print(self._board.assets())
# print(self._board.lemonade_cost())
# print(self._board.weather_forecast())
# print(self._board.history())
# print(self._board.messages())
print(self._board.to_string())
# TODO: Implement your logic here
_glassesToMake = 2
_signsToMake = 0
_lemonadePriceCents = 15
_answer = "message('go {},{},{}')".format(_glassesToMake, _signsToMake, _lemonadePriceCents)
return _answer
示例9: Board
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
### CHOOSING THE BOARD ###
board = Board(6, 4)
board.initialize_king_and_rook()
game_stats = Stats(game, x)
### MAIN GAME LOOP ###
start = time.time()
while game.is_terminal(board) is False:
search = SeachMethod(SeachMethod.AIMA_ALPHABETA_SEARCH, 2)
game_stats.set_search_method(SeachMethod.AIMA_ALPHABETA_SEARCH)
move = search.search(board, game)
game_stats.add_expanded_nodes(game.get_player_turn(), search.get_expand_nodes())
board.move_piece(move[0][0], move[0][1], move[1][0], move[1][1])
game_stats.add_visit_nodes(game.get_player_turn().get_color())
game.change_turn()
print board.to_string()
game_stats.set_game_time(time.time() - start)
print game.get_player_turn().to_string() + ", YOU HAVE BEEN DEFEATED!"
game_stats.set_winner(game.get_player_turn())
### CREATING THE GAME INSTANCE ###
game = Game(player_two, player_one)
### CHOOSING THE BOARD ###
board = Board(6, 4)
board.initialize_king_and_rook()
game_stats_two = Stats(game, x+1)
start = time.time()
示例10: test_moves1
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_moves1():
b = Board()
b.move_algebraic("e4")
assert b.to_string() == \
"RNBQKBNRPPPPPPPP p pppp ppprnbqkbnr"
示例11: test_setup1
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import to_string [as 别名]
def test_setup1():
b = Board()
assert b.to_string() == \
"RNBQKBNRPPPPPPPP pppppppprnbqkbnr"