Action SDLKeyboardAgent::act() { if (manual_control) { return waitForKeypress(); } else // Default to random agent return choice(&available_actions); }
/** This methods handles the basic agent functionality: bookeeping * the number of episodes, frames, etc... It calls the method * act(), which will provide it with an action. act() which should * be overriden by subclasses. */ Action PlayerAgent::agent_step() { // Terminate if we have a maximum number of frames if (i_max_num_frames > 0 && frame_number >= i_max_num_frames) end_game(); // Terminate this episode if we have reached the max. number of frames if (i_max_num_frames_per_episode > 0 && episode_frame_number >= i_max_num_frames_per_episode) { return RESET; } // Only take an action if manual control is disabled Action a; if (manual_control) { a = waitForKeypress(); } else { a = act(); } if (record_trajectory) record_action(a); frame_number++; episode_frame_number++; return a; }
int main(int argc, char **argv) { po::options_description desc("Options"); desc.add_options() ("help,h", "Print help messages") ("indir", po::value<std::string>()->required(), "input directory") ("outdir", po::value<std::string>()->required(), "output directory"); po::positional_options_description posOpt; posOpt.add("indir", 1); posOpt.add("outdir", 1); po::variables_map vm; try { po::store(po::command_line_parser(argc, argv) .options(desc).positional(posOpt).run(), vm); if (vm.count("help") ) { std::cout << "Usage: stacktr INDIR OUTDIR" << std::endl; std::cout << std::endl; std::cout << " INDIR is the input directory" << std::endl; std::cout << " OUTDIR is the output directory" << std::endl; return 0; } po::notify(vm); // } catch (po::required_option &e) { std::cerr << "Missing a required option" << std::endl; return 1; } catch (po::error &e) { std::cerr << "Something wrong during the parsing" << std::endl; return 2; } std::cout << std::endl; fs::path inDir(vm["indir"].as<std::string>()); fs::path outDir(vm["outdir"].as<std::string>()); std::vector<fs::path> fileList; retrieveFileList(fileList, inDir); // Create folder if not exist. boost::system::error_code retErr; fs::create_directories(outDir, retErr); if (!retErr) { std::cout << "Output directory created" << std::endl; } // Transposed stack will contain as much layer as the amount of stacks. size_t nLayer = fileList.size(); processFileList(fileList, outDir, static_cast<uint16_t>(nLayer)); waitForKeypress(); return 0; }