#NEWLINE# def sgf_iter_states( sgf_string ) : #NEWLINE# #INDENT# "Iterates over (GameState, move, player) tuples in the first game of the given SGF file.\n\n\tIgnores variations - only the main line is returned.\n\n\tNote that the final tuple returned is the penultimate state,\n\tbut because 'gs' is modified in-place the state is at the final\n\tposition after iteration completes. See sgf_to_gamestate\n\t" #NEWLINE# collection = sgf . parse ( sgf_string ) #NEWLINE# game = collection [ 0 ] #NEWLINE# gs = _sgf_init_gamestate ( game . root ) #NEWLINE# for node in game . rest : #NEWLINE# #INDENT# props = node . properties #NEWLINE# if ( 'W' in props ) : #NEWLINE# #INDENT# move = _parse_sgf_move ( props [ 'W' ] [ 0 ] ) #NEWLINE# player = go . WHITE #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'B' in props ) : #NEWLINE# #INDENT# move = _parse_sgf_move ( props [ 'B' ] [ 0 ] ) #NEWLINE# player = go . BLACK #NEWLINE# #UNINDENT# #UNINDENT# ( yield ( gs , move , player ) ) #NEWLINE# gs . do_move ( move , player )