Autoload variants.ini if specified in by an environment variable (#360)
authorTerry Hearst <thearst3rd@gmail.com>
Fri, 17 Sep 2021 07:03:25 +0000 (03:03 -0400)
committerGitHub <noreply@github.com>
Fri, 17 Sep 2021 07:03:25 +0000 (09:03 +0200)
src/uci.cpp

index 5b5aaa7..ef6a6cf 100644 (file)
@@ -16,6 +16,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include <cstdlib>
 #include <cassert>
 #include <cmath>
 #include <iostream>
@@ -287,6 +288,19 @@ void UCI::loop(int argc, char* argv[]) {
   // UCCI banmoves state
   std::vector<Move> banmoves = {};
 
+  if (argc > 1 && (std::strcmp(argv[1], "noautoload") == 0))
+  {
+      cmd = "";
+      argc = 1;
+  }
+  else if (argc == 1 || !(std::strcmp(argv[1], "load") == 0))
+  {
+      // Check environment for variants.ini file
+      char *envVariantPath = std::getenv("FAIRY_STOCKFISH_VARIANT_PATH");
+      if (envVariantPath != NULL)
+          Options["VariantPath"] = std::string(envVariantPath);
+  }
+
   do {
       if (argc == 1 && !getline(cin, cmd)) // Block here waiting for input or EOF
           cmd = "quit";