def save_games()

in pachi_py/extra_unused.pyx [0:0]


def save_games(games):
    cdef int out_size = 0
    for transitions in games:
        out_size += 2 + 2*len(transitions)

    cdef np.ndarray[np.uint8_t,ndim=1] out = np.empty(out_size, np.uint8)
    cdef PyPachiBoard init_state
    cdef Transition t
    cdef unsigned int pos = 0
    for transitions in games:
        init_state = transitions[0].state
        assert init_state.empty, "only supports games starting from the empty state"
        assert 0 <= init_state.size() < 256
        assert 0 <= len(transitions) < 256
        out[pos] = init_state.size()
        out[pos+1] = len(transitions)
        pos += 2
        for t in transitions:
            assert 0 <= t.player < 256
            assert 0 <= t.action < 256
            out[pos] = t.player
            out[pos+1] = t.action
            pos += 2
    assert pos == out_size

    return out