Example #1
0
 public Trainer()
 {
     TrainerSettings = new TrainerSettings();
 }
Example #2
0
        static Command ParseArguments(string[] args, TrainerSettings trainerSettings)
        {
            if (null == args || args.Length == 0)
            {
                throw new ArgumentNullException("args");
            }

            if (null == trainerSettings)
            {
                throw new ArgumentNullException("trainerSettings");
            }

            Command cmd = Command.Unknown;

            switch (args[0].ToLower())
            {
            case "b":
            case "battle":
                cmd = Command.Battle;
                break;

            case "br":
            case "battleroyale":
                cmd = Command.BattleRoyale;
                break;

            case "c":
            case "cull":
                cmd = Command.Cull;
                break;

            case "e":
            case "enumerate":
                cmd = Command.Enumerate;
                break;

            case "a":
            case "analyze":
                cmd = Command.Analyze;
                break;

            case "g":
            case "generate":
                cmd = Command.Generate;
                break;

            case "l":
            case "lifecycle":
                cmd = Command.Lifecycle;
                break;

            case "m":
            case "mate":
                cmd = Command.Mate;
                break;

            case "t":
            case "tournament":
                cmd = Command.Tournament;
                break;

            case "at":
            case "autotrain":
                cmd = Command.AutoTrain;
                break;
            }

            if (cmd == Command.Unknown)
            {
                throw new Exception(string.Format("Unknown command: {0}", args[0]));
            }

            for (int i = 1; i < args.Length; i++)
            {
                switch (args[i].Substring(1).ToLower())
                {
                case "pp":
                case "profilespath":
                    trainerSettings.ProfilesPath = args[++i];
                    break;

                case "wpp":
                case "whiteprofilepath":
                    trainerSettings.WhiteProfilePath = args[++i];
                    break;

                case "bpp":
                case "blackprofilepath":
                    trainerSettings.BlackProfilePath = args[++i];
                    break;

                case "ckc":
                case "cullkeepcount":
                    trainerSettings.CullKeepCount = int.Parse(args[++i]);
                    break;

                case "gc":
                case "generatecount":
                    trainerSettings.GenerateCount = int.Parse(args[++i]);
                    break;

                case "gminw":
                case "generateminweight":
                    trainerSettings.GenerateMinWeight = double.Parse(args[++i]);
                    break;

                case "gmaxw":
                case "generatemaxweight":
                    trainerSettings.GenerateMaxWeight = double.Parse(args[++i]);
                    break;

                case "lg":
                case "lifecyclegenerations":
                    trainerSettings.LifecycleGenerations = int.Parse(args[++i]);
                    break;

                case "lb":
                case "lifecyclebattles":
                    trainerSettings.LifecycleBattles = int.Parse(args[++i]);
                    break;

                case "mb":
                case "maxbattles":
                    trainerSettings.MaxBattles = int.Parse(args[++i]);
                    break;

                case "mcb":
                case "maxconcurrentbattles":
                    trainerSettings.MaxConcurrentBattles = int.Parse(args[++i]);
                    break;

                case "bsp":
                case "battleshuffleprofiles":
                    trainerSettings.BattleShuffleProfiles = bool.Parse(args[++i]);
                    break;

                case "mdraws":
                case "maxdraws":
                    trainerSettings.MaxDraws = int.Parse(args[++i]);
                    break;

                case "bbtl":
                case "bulkbattletimelimit":
                    trainerSettings.BulkBattleTimeLimit = TimeSpan.Parse(args[++i]);
                    break;

                case "pr":
                case "provisionalrules":
                    trainerSettings.ProvisionalRules = bool.Parse(args[++i]);
                    break;

                case "pgc":
                case "provisionalgamecount":
                    trainerSettings.ProvisionalGameCount = int.Parse(args[++i]);
                    break;

                case "mminm":
                case "mateminmix":
                    trainerSettings.MateMinMix = double.Parse(args[++i]);
                    break;

                case "mmaxm":
                case "matemaxmix":
                    trainerSettings.MateMaxMix = double.Parse(args[++i]);
                    break;

                case "mpc":
                case "mateparentcount":
                    trainerSettings.MateParentCount = int.Parse(args[++i]);
                    break;

                case "msp":
                case "mateshuffleparents":
                    trainerSettings.MateShuffleParents = bool.Parse(args[++i]);
                    break;

                case "tts":
                case "TransTableSize":
                    trainerSettings.TransTableSize = int.Parse(args[++i]);
                    break;

                case "mdepth":
                case "maxdepth":
                    trainerSettings.MaxDepth = int.Parse(args[++i]);
                    break;

                case "tmt":
                case "turnmaxtime":
                    trainerSettings.TurnMaxTime = TimeSpan.Parse(args[++i]);
                    break;

                case "btl":
                case "battletimelimit":
                    trainerSettings.BattleTimeLimit = TimeSpan.Parse(args[++i]);
                    break;

                case "gt":
                case "gametype":
                    trainerSettings.GameType = EnumUtils.ParseExpansionPieces(args[++i]);
                    break;

                case "tpp":
                case "targetprofilepath":
                    trainerSettings.TargetProfilePath = args[++i];
                    break;

                case "findpuzzlecandidates":
                case "fpc":
                    trainerSettings.FindPuzzleCandidates = bool.Parse(args[++i]);
                    break;

                case "maxhelperthreads":
                case "mht":
                    trainerSettings.MaxHelperThreads = int.Parse(args[++i]);
                    break;

                default:
                    throw new Exception(string.Format("Unknown parameter: {0}", args[i]));
                }
            }

            return(cmd);
        }