Implements AI Switching
All checks were successful
Build / Build (push) Successful in 58s

This commit is contained in:
2025-07-12 13:03:00 +02:00
parent 364d4b9080
commit bf83b25238
34 changed files with 903 additions and 226 deletions

View File

@@ -5,6 +5,8 @@ using PkmnLib.Dynamic.AI;
using PkmnLib.Dynamic.Libraries;
using PkmnLib.Plugin.Gen7;
using Serilog;
using Serilog.Core;
using Serilog.Events;
namespace AIRunner;
@@ -12,9 +14,12 @@ internal static class Program
{
private static List<PokemonAI>? _availableAIs;
internal static LoggingLevelSwitch LogLevelSwitch { get; } = new(LogEventLevel.Information);
private static Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration().MinimumLevel.Information().WriteTo.Console().CreateLogger();
Log.Logger = new LoggerConfiguration().MinimumLevel.ControlledBy(LogLevelSwitch).WriteTo.Console()
.CreateLogger();
Log.Information("Starting AI Runner...");
AILogging.LogHandler = Log.Debug;
var library = DynamicLibraryImpl.Create([
@@ -24,6 +29,10 @@ internal static class Program
var testCommand = new Command("test", "Run two AIs against each other")
{
new Option<bool>("--debug")
{
Description = "Enable debug logging.",
},
new Option<string>("--ai1")
{
Description = "The name of the first AI script to run against the second AI.",
@@ -55,6 +64,9 @@ internal static class Program
};
testCommand.SetAction(result =>
{
var debug = result.GetValue<bool>("--debug");
LogLevelSwitch.MinimumLevel = debug ? LogEventLevel.Debug : LogEventLevel.Information;
var ai1Name = result.GetRequiredValue<string>("--ai1");
var ai2Name = result.GetRequiredValue<string>("--ai2");
var ai1 = _availableAIs!.First(a =>