def _sgf_init_gamestate(sgf_root):
 props = sgf_root.properties
 s_size = props.get('SZ', ['19'])[0]
 s_player = props.get('PL', ['B'])[0]
 gs = go.GameState(int(s_size))
 if ('AB' in props):
  for stone in props['AB']:
   gs.do_move(_parse_sgf_move(stone), go.BLACK)
 if ('AW' in props):
  for stone in props['AW']:
   gs.do_move(_parse_sgf_move(stone), go.WHITE)
 gs.current_player = (go.BLACK if (s_player == 'B') else go.WHITE)
 return gs

def _sgf_init_gamestate ( sgf_root ) : props = sgf_root . properties s_size = props . get ( 'SZ' , [ '19' ] ) [ 0 ] s_player = props . get ( 'PL' , [ 'B' ] ) [ 0 ] gs = go . GameState ( int ( s_size ) ) if ( 'AB' in props ) : for stone in props [ 'AB' ] : gs . do_move ( _parse_sgf_move ( stone ) , go . BLACK ) if ( 'AW' in props ) : for stone in props [ 'AW' ] : gs . do_move ( _parse_sgf_move ( stone ) , go . WHITE ) gs . current_player = ( go . BLACK if ( s_player == 'B' ) else go . WHITE ) return gs
helper function to set up a gamestate object from the root node of an sgf file .