예제 #1
0
            print("level is loaded")

        elif game_state == 'LOADING':
            print("########################################################")
            print("Loading state")
            pass
        elif game_state == 'WON':
            print("########################################################")
            print("Won state")
            # resater random level
            if angle_action_idx != len(valid_angles) - 1:
                angle_action_idx += 1
                comm.comm_restart_level(s)
            elif angle_action_idx == len(valid_angles) - 1:
                angle_action_idx = 0
                if comm.comm_get_current_level(s) < 21:
                    load_level += 1
                    comm.comm_load_level(s, load_level)
                else:
                    break

        elif game_state == 'LOST':
            print("########################################################")
            print("Lost state")
            # restart random level
            if angle_action_idx != len(valid_angles) - 1:
                angle_action_idx += 1
                comm.comm_restart_level(s)
            elif angle_action_idx == len(valid_angles) - 1:
                angle_action_idx = 0
                if comm.comm_get_current_level(s) < 21:
예제 #2
0
            # lost_flag = 1
            comm.comm_restart_level(s)

        elif game_state == 'PLAYING':
            print("########################################################")
            print("Playing state")

            i_episode += 1

            episode_dir = "%s_%d" % (run_start_dir, i_episode)
            if not os.path.exists(episode_dir):
                os.mkdir(episode_dir)

            # 새 에피소드 시작할 때마다 checkpoint 새로 생성
            # saver.save(sess, checkpoint_path) # 뭔가 thread안이랑 밖이랑 같이 저장하면서 checkpoint temp가 충돌?? 하는 것 같은 오류가..
            current_level = comm.comm_get_current_level(s)

            i_episodes[current_level - 1] += 1

            print("=============== Level", current_level, "===============")

            for t in itertools.count():  # 이 에피소드가 끝날때까지

                # pdb.set_trace()
                print('\n')
                print("\rStep {} ({}) @ Episode {} (Level {})".format(
                    t, total_t, i_episode, current_level),
                      end="\n")
                sys.stdout.flush()

                shot_dir = os.path.join(