public SinglePlayerClient(PBEBattleFormat battleFormat, PBESettings settings, IReadOnlyList <PBETrainerInfo> ti0, IReadOnlyList <PBETrainerInfo> ti1, string name) : base(name) { var b = new PBEBattle(battleFormat, settings, ti0, ti1, battleTerrain: PBERandom.RandomBattleTerrain()); Battle = b; Trainer = b.Trainers[0]; BattleView = new BattleView(this); b.OnNewEvent += SinglePlayerBattle_OnNewEvent; b.OnStateChanged += SinglePlayerBattle_OnStateChanged; new Thread(b.Begin) { Name = "Battle Thread" }.Start(); }
public static void Run() { Console.WriteLine("----- Pokémon Battle Engine - AI Battle Demo -----"); try { _writer = new StreamWriter(new FileStream(LogFile, FileMode.Create, FileAccess.Write)); } catch (Exception e) { Console.WriteLine($"Cannot open \"{LogFile}\" for writing."); Console.WriteLine(e.Message); return; } PBESettings settings = PBESettings.DefaultSettings; //var settings = new PBESettings { NumMoves = 8, MaxPartySize = 10 }; //settings.MakeReadOnly(); PBELegalPokemonCollection p0, p1; // Competitively Randomized Pokémon p0 = PBERandomTeamGenerator.CreateRandomTeam(settings.MaxPartySize); p1 = PBERandomTeamGenerator.CreateRandomTeam(settings.MaxPartySize); _battle = new PBEBattle(PBEBattleFormat.Double, settings, new PBETrainerInfo(p0, "Trainer 0"), new PBETrainerInfo(p1, "Trainer 1"), battleTerrain: PBERandom.RandomBattleTerrain()); _battle.OnNewEvent += PBEBattle.ConsoleBattleEventHandler; _battle.OnNewEvent += Battle_OnNewEvent; _battle.OnStateChanged += Battle_OnStateChanged; _oldWriter = Console.Out; Console.SetOut(_writer); new Thread(() => { try { _battle.Begin(); } catch (Exception e) { CatchException(e); } }) { Name = "Battle Thread" }.Start(); }