def reconstruct_games()

in pachi_py/extra_unused.pyx [0:0]


def reconstruct_games(np.uint8_t[:] data):
    cdef int i, gamelen, boardsize, pos = 0
    cdef vector[np.uint8_t] players, actions
    cdef PyPachiBoard b, b2

    games = []
    while pos < len(data):
        # read board size, game length, and actions
        boardsize = data[pos]
        gamelen = data[pos+1]
        players.clear(); actions.clear()
        for i in range(gamelen):
            players.push_back(data[pos+2 + 2*i])
            actions.push_back(data[pos+2 + 2*i+1])
        pos += 2 + 2*gamelen

        # replay
        transitions = []
        b = CreateBoard(boardsize)
        for i in range(gamelen):
            b2 = b.play(actions[i], players[i])
            transitions.append(Transition(
                player=players[i], state=b, action=actions[i], next_state=b2))
            b = b2
        games.append(transitions)

        if len(games) % 1000 == 0:
            print '[%.2f%%]' % (100.*float(pos)/len(data))

    assert pos == len(data)
    return games