implementation of gen_initial_state

please lord actually work