<commit_before>﻿// Copyright (c) <NAME> <http://jonthysell.com>
// Licensed under the MIT License.

using System;
using System.Text;

using Mzinga.Core;

namespace Mzinga.Trainer
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            try
            {
                Console.WriteLine($"{AppInfo.Name} v{AppInfo.Version}");
                Console.WriteLine();

                if (args.Length == 0)
                {
                    ShowHelp();
                }
                else
                {
                    Trainer t = new Trainer();

                    Command cmd = ParseArguments(args, t.TrainerSettings);

                    switch (cmd)
                    {
                        case Command.Battle:
                            t.Battle();
                            break;
                        case Command.BattleRoyale:
                            t.BattleRoyale();
                            break;
                        case Command.Cull:
                            t.Cull();
                            break;
                        case Command.Enumerate:
                            t.Enumerate();
                            break;
                        case Command.Analyze:
                            t.Analyze();
                            break;
                        case Command.Generate:
                            t.Generate();
                            break;
                        case Command.Lifecycle:
                            t.Lifecycle();
                            break;
                        case Command.Mate:
                            t.Mate();
                            break;
                        case Command.Tournament:
                            t.Tournament();
                            break;
                        case Command.AutoTrain:
                            t.AutoTrain();
                            break;
                        case Command.Top:
                            t.Top();
                            break;
                        case Command.MergeTop:
                            t.MergeTop();
                            break;
                        case Command.ExportAI:
                            t.ExportAI();
                            break;
                        default:
                            ShowHelp();
                            break;
                    }
                }
            }
            catch (AggregateException ex)
            {
                PrintException(ex);
                foreach (Exception innerEx in ex.InnerExceptions)
                {
                    PrintException(innerEx);
                }
            }
            catch (Exception ex)
            {
                PrintException(ex);
            }
        }

        static void PrintException(Exception ex)
        {
            ConsoleColor oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Red;

            Console.WriteLine();
            Console.Error.WriteLine("Error: {0}", ex.Message);
            Console.Error.WriteLine(ex.StackTrace);

            Console.ForegroundColor = oldColor;

            if (ex.InnerException is not null)
            {
                PrintException(ex.InnerException);
            }
        }

        static void ShowHelp()
        {
            Console.WriteLine("Usage:");
            Console.WriteLine($"{AppInfo.Name} [command] ([parametername] [parametervalue]...)");
            Console.WriteLine();

            Console.WriteLine("Example:");
            Console.WriteLine($"{AppInfo.Name} enumerate -ProfilesPath c:\\profiles\\");
            Console.WriteLine();

            Console.WriteLine("Commands:");

            Console.WriteLine("battle                 Fight a single battle between two profiles");
            Console.WriteLine("battleroyale           Fight every profile against each other");
            Console.WriteLine("cull                   Delete the lowest ranking profiles");
            Console.WriteLine("enumerate              List all of the profiles");
            Console.WriteLine("analyze                Analyze all of the profiles");
            Console.WriteLine("generate               Create new random profiles");
            Console.WriteLine("lifecycle              Battle, cull, mate cycle for profiles");
            Console.WriteLine("mate                   Mate every profile with each other");
            Console.WriteLine("tournament             Fight an single elimination tournament");
            Console.WriteLine("autotrain              Train a single profile against itself");
            Console.WriteLine("top                    List the top profiles for each GameType");
            Console.WriteLine("mergetop               Merge the top profiles from each GameType");
            Console.WriteLine("exportai               Export the current engine AI as profiles");
            Console.WriteLine("buildinitialtables     Build and export InitialTranspositionTable");

            Console.WriteLine();

            Console.WriteLine("Parameters:");

            Console.WriteLine("-ProfilesPath          Where the profiles are stored");
            Console.WriteLine("-WhiteProfilePath      The white profile in a single battle");
            Console.WriteLine("-BlackProfilePath      The black profile in a single battle");
            Console.WriteLine("-CullKeepCount         How many to profiles to keep when culling");
            Console.WriteLine("-GenerateCount         How many profiles to generate");
            Console.WriteLine("-GenerateMinWeight     The minimum weight value for random profiles");
            Console.WriteLine("-GenerateMaxWeight     The maximum weight value for random profiles");
            Console.WriteLine("-LifecycleGenerations  The number of generations to run");
            Console.WriteLine("-LifecycleBattles      The number/type of battles in each generation");
            Console.WriteLine("-MaxBattles            The max number of battles in a battle royale");
            Console.WriteLine("-MaxConcurrentBattles  The max number of battles at the same time");
            Console.WriteLine("-BattleShuffleProfiles Whether or not to have profiles fight in random order");
            Console.WriteLine("-BulkBattleTimeLimit   The max time for tournaments / battle royales");
            Console.WriteLine("-ProvisionalRules      Whether or not to use provisional rules");
            Console.WriteLine("-ProvisionalGameCount  The number of games a profile stays provisional");
            Console.WriteLine("-MaxDraws              The max number of times to retry battles that end in a draw");
            Console.WriteLine("-MateMinMix            The min multiplier to mix up weights in children profiles");
            Console.WriteLine("-MateMaxMix            The max multiplier to mix up weights in children profiles");<commit_msg>Trainer: Removed buildinitialtables command from help<commit_after>﻿// Copyright (c) <NAME> <http://jonthysell.com>
// Licensed under the MIT License.

using System;
using System.Text;

using Mzinga.Core;

namespace Mzinga.Trainer
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            try
            {
                Console.WriteLine($"{AppInfo.Name} v{AppInfo.Version}");
                Console.WriteLine();

                if (args.Length == 0)
                {
                    ShowHelp();
                }
                else
                {
                    Trainer t = new Trainer();

                    Command cmd = ParseArguments(args, t.TrainerSettings);

                    switch (cmd)
                    {
                        case Command.Battle:
                            t.Battle();
                            break;
                        case Command.BattleRoyale:
                            t.BattleRoyale();
                            break;
                        case Command.Cull:
                            t.Cull();
                            break;
                        case Command.Enumerate:
                            t.Enumerate();
                            break;
                        case Command.Analyze:
                            t.Analyze();
                            break;
                        case Command.Generate:
                            t.Generate();
                            break;
                        case Command.Lifecycle:
                            t.Lifecycle();
                            break;
                        case Command.Mate:
                            t.Mate();
                            break;
                        case Command.Tournament:
                            t.Tournament();
                            break;
                        case Command.AutoTrain:
                            t.AutoTrain();
                            break;
                        case Command.Top:
                            t.Top();
                            break;
                        case Command.MergeTop:
                            t.MergeTop();
                            break;
                        case Command.ExportAI:
                            t.ExportAI();
                            break;
                        default:
                            ShowHelp();
                            break;
                    }
                }
            }
            catch (AggregateException ex)
            {
                PrintException(ex);
                foreach (Exception innerEx in ex.InnerExceptions)
                {
                    PrintException(innerEx);
                }
            }
            catch (Exception ex)
            {
                PrintException(ex);
            }
        }

        static void PrintException(Exception ex)
        {
            ConsoleColor oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Red;

            Console.WriteLine();
            Console.Error.WriteLine("Error: {0}", ex.Message);
            Console.Error.WriteLine(ex.StackTrace);

            Console.ForegroundColor = oldColor;

            if (ex.InnerException is not null)
            {
                PrintException(ex.InnerException);
            }
        }

        static void ShowHelp()
        {
            Console.WriteLine("Usage:");
            Console.WriteLine($"{AppInfo.Name} [command] ([parametername] [parametervalue]...)");
            Console.WriteLine();

            Console.WriteLine("Example:");
            Console.WriteLine($"{AppInfo.Name} enumerate -ProfilesPath c:\\profiles\\");
            Console.WriteLine();

            Console.WriteLine("Commands:");

            Console.WriteLine("battle                 Fight a single battle between two profiles");
            Console.WriteLine("battleroyale           Fight every profile against each other");
            Console.WriteLine("cull                   Delete the lowest ranking profiles");
            Console.WriteLine("enumerate              List all of the profiles");
            Console.WriteLine("analyze                Analyze all of the profiles");
            Console.WriteLine("generate               Create new random profiles");
            Console.WriteLine("lifecycle              Battle, cull, mate cycle for profiles");
            Console.WriteLine("mate                   Mate every profile with each other");
            Console.WriteLine("tournament             Fight an single elimination tournament");
            Console.WriteLine("autotrain              Train a single profile against itself");
            Console.WriteLine("top                    List the top profiles for each GameType");
            Console.WriteLine("mergetop               Merge the top profiles from each GameType");
            Console.WriteLine("exportai               Export the current engine AI as profiles");

            Console.WriteLine();

            Console.WriteLine("Parameters:");

            Console.WriteLine("-ProfilesPath          Where the profiles are stored");
            Console.WriteLine("-WhiteProfilePath      The white profile in a single battle");
            Console.WriteLine("-BlackProfilePath      The black profile in a single battle");
            Console.WriteLine("-CullKeepCount         How many to profiles to keep when culling");
            Console.WriteLine("-GenerateCount         How many profiles to generate");
            Console.WriteLine("-GenerateMinWeight     The minimum weight value for random profiles");
            Console.WriteLine("-GenerateMaxWeight     The maximum weight value for random profiles");
            Console.WriteLine("-LifecycleGenerations  The number of generations to run");
            Console.WriteLine("-LifecycleBattles      The number/type of battles in each generation");
            Console.WriteLine("-MaxBattles            The max number of battles in a battle royale");
            Console.WriteLine("-MaxConcurrentBattles  The max number of battles at the same time");
            Console.WriteLine("-BattleShuffleProfiles Whether or not to have profiles fight in random order");
            Console.WriteLine("-BulkBattleTimeLimit   The max time for tournaments / battle royales");
            Console.WriteLine("-ProvisionalRules      Whether or not to use provisional rules");
            Console.WriteLine("-ProvisionalGameCount  The number of games a profile stays provisional");
            Console.WriteLine("-MaxDraws              The max number of times to retry battles that end in a draw");
            Console.WriteLine("-MateMinMix            The min multiplier to mix up weights in children profiles");
            Console.WriteLine("-MateMaxMix            The max multiplier to mix up weights in children profiles");
{'fraction_non_alphanumeric': 0.07626154939587776, 'fraction_numerical': 0.00042643923240938164, 'mean_word_length': 1.2313669521091024, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2736283', 'n_tokens_mistral': 2925, 'n_tokens_neox': 2832, 'n_words': 817}