decodeState funtion, inverse to game_state