-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
game.get_sequence() result like on sgf file #28
Comments
the functionality you are looking for would come from using >>> sequence = game.get_sequence()
>>> first_five_moves = sequence[:5]
>>> last_2_moves = sequence[-2:]
>>> reversed = sequence[::-1] |
the code on initial issue is the shortest one, here what i want to achieve
it works but not expected, best regards |
What you want to do is use |
Full code with the change def random_player(game):
move = random.choice(list(game.get_legal_moves() ) )
return move
def play_game(player1, player2):
game = sente.Game(9, sente.rules.JAPANESE)
try:
while not game.is_over():
move = random_player(game)
game.play(move)
clear_output(wait = True)
print(game)
except KeyboardInterrupt:
msg = "Game interrupted!"
return (None, msg, game)
file_sgf = "sgf/sente-random_player.sgf"
sgf.dump(game, file_sgf)
print('Winner :', game.get_winner() )
print('Game Sequence :', sgf.dumps(game)) |
already tested before result expected result think like *.pgn on chess, sometime others want to learn the sequence move of players, in python chess module https://pypi.org/project/chess/, it can be achieve using |
I think this is what you should do as a workaround then: def move_str(move):
"""
translates a move into a string
:param move: move to translate into a string
:returns: string representation of the move
"""
color = move.get_color()
x = move.get_x()
y = move.get_y()
if x >= ord("i"):
x += 1
if y >= ord("i"):
y += 1
return color + "[" + chr(x) + chr(y) + "]" you can then apply the function to the entire list and join the new list with semicolons. >>> sequence = game.get_sequence()
>>> sequence = [move_to_str(move) for move in sequence]
>>> print(";".join(sequence)) When I get the chance I will make it so that calling |
Fixed in sente v0.4.2 |
result
expected result like on sgf file, more human readable
question
how to achieve it in sente ?
thanks and best regards,
The text was updated successfully, but these errors were encountered: