google-deepmind / open_spiel

OpenSpiel is a collection of environments and algorithms for research in general reinforcement learning and search/planning in games.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug in chess terminal determination?

XintianHan opened this issue · comments

I just tried the following code

env = pyspiel.load_game("chess")
state = env.new_initial_state()
while not state.is_terminal():
    actions = state.legal_actions(state.current_player())
    spiel_actions = np.array(sorted(actions))
    state.apply_action(spiel_actions[0])
print(str(state))

It seems that the game ended earlier before the terminal. I checked the print of the state at the last line. It's 1nbqkbnr/rppppppp/p7/8/8/P7/RPPPPPPP/1NBQKBNR w Kk - 10 7

It does not seem to be the end of the game. What's wrong here? Thanks in advance!

Hi, I think this is because a state is getting repeated 3 times: https://en.wikipedia.org/wiki/Threefold_repetition

Checked by this function:

// Draw can be claimed under the FIDE 3-fold repetition rule (the current

Use print(state.debug_string()) throughout the history to see it visually.

Hi, I think this is because a state is getting repeated 3 times: https://en.wikipedia.org/wiki/Threefold_repetition

Checked by this function:

// Draw can be claimed under the FIDE 3-fold repetition rule (the current

Use print(state.debug_string()) throughout the history to see it visually.

Thanks! This actually the case!