From 6fc3580102651663662b499236fefe5b73832695 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sat, 10 Aug 2024 14:59:32 -0500 Subject: [PATCH] options: add help option and rename bot argument for later --- src/main.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 14f389d..fd25643 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,19 +4,36 @@ #include #include +void Help(void) { + std::cout << "Usage: snakeplusplus [OPTIONS]" << std::endl; + std::cout << "Options:" << std::endl; + std::cout << "\t--server\tRun snake in server mode (also sets --bot)" << std::endl; + std::cout << "\t--auto\t\tControl snake using a bot or AI" << std::endl; + std::cout << "\t-h, --help\tPrint this help message and exit" << std::endl; + std::cout << std::endl; + std::cout << "Autoplay options (requires --auto):" << std::endl; + std::cout << "\t--dumb\t\tPlays using basic search algorithms BFS and DFS" << std::endl; + std::cout << "\t--smart\t\tTrains an algorithm using unsupervised learning" << std::endl; + std::cout << std::endl; +} + int main(int argc, char* argv[]) { std::vector args(argv, argv + argc); g_pEngine = std::make_unique(); for (int i = 1; i < args.size(); ++i) { - if (args[i].compare("--no-gui") == 0) { + if (args[i].compare("--server") == 0) { g_pEngine->state.m_bNoDisplay = true; g_pEngine->state.m_bIsBotControlled = true; std::cout << "[LOG - Main] Disabling display" << std::endl; - } else if (args[i].compare("--bot") == 0) { + } else if (args[i].compare("--auto") == 0) { g_pEngine->state.m_bIsBotControlled = true; std::cout << "[LOG - Main] Bot control enabled" << std::endl; + } else if (args[i].compare("-h") == 0 || args[i].compare("--help") == 0) { + Help(); + return 0; } else { - std::cerr << "[ERROR] Argument " << args[i].c_str() << "not found, exiting..." << std::endl; + std::cout << "[LOG - Main] Argument `" << args[i] << "` unrecognized, printing help and exiting..."<< std::endl; + Help(); return 1; } }