2024-08-02 19:50:48 -05:00
|
|
|
#include "gamestate.hpp"
|
|
|
|
#include <memory>
|
2024-08-02 21:23:49 -05:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
2024-08-02 19:50:48 -05:00
|
|
|
|
2024-08-10 14:59:32 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-08-03 18:40:38 -05:00
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
std::vector<std::string> args(argv, argv + argc);
|
|
|
|
g_pEngine = std::make_unique<GameEngine>();
|
|
|
|
for (int i = 1; i < args.size(); ++i) {
|
2024-08-10 14:59:32 -05:00
|
|
|
if (args[i].compare("--server") == 0) {
|
2024-08-02 21:23:49 -05:00
|
|
|
g_pEngine->state.m_bNoDisplay = true;
|
2024-08-03 18:41:36 -05:00
|
|
|
g_pEngine->state.m_bIsBotControlled = true;
|
2024-08-03 01:26:10 -05:00
|
|
|
std::cout << "[LOG - Main] Disabling display" << std::endl;
|
2024-08-10 14:59:32 -05:00
|
|
|
} else if (args[i].compare("--auto") == 0) {
|
2024-08-03 18:34:14 -05:00
|
|
|
g_pEngine->state.m_bIsBotControlled = true;
|
|
|
|
std::cout << "[LOG - Main] Bot control enabled" << std::endl;
|
2024-08-10 14:59:32 -05:00
|
|
|
} else if (args[i].compare("-h") == 0 || args[i].compare("--help") == 0) {
|
|
|
|
Help();
|
|
|
|
return 0;
|
2024-08-02 21:23:49 -05:00
|
|
|
} else {
|
2024-08-10 14:59:32 -05:00
|
|
|
std::cout << "[LOG - Main] Argument `" << args[i] << "` unrecognized, printing help and exiting..."<< std::endl;
|
|
|
|
Help();
|
2024-08-02 21:23:49 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2024-08-02 19:50:48 -05:00
|
|
|
g_pEngine->Start();
|
|
|
|
return 0;
|
|
|
|
}
|