コード例 #1
0
        private static void RunServer([NotNull] IEnumerable <string> args)
        {
            var staticContentPath    = GetStaticContentDir();
            var settings             = GetSettingsFile(args);
            var httpListenerPrefix   = settings.HttpListenerPrefix;
            var warriorProgramParser = new WarriorParser();
            var playersRepo          = new PlayersRepo(new DirectoryInfo("../players"), warriorProgramParser);
            var gamesRepo            = new CachingGamesRepo(new GamesRepo(new DirectoryInfo("../games")));
            var sessionManager       = new SessionManager("../sessions");
            var gameServer           = new GameServer();
            var debuggerManager      = new DebuggerManager(gameServer);
            var battleRunner         = new BattleRunner();
            var countdownProvider    = new CountdownProvider(settings.ContestStartTimestamp, TimeSpan.FromHours(settings.ContestDurationInHours));
            var arenaState           = new ArenaState(playersRepo, gamesRepo, countdownProvider, settings.GodModeSecret, settings.GodAccessOnly, settings.SubmitIsAllowed, settings.EnableDeepNavigation);
            var tournamentRunner     = new TournamentRunner(arenaState, battleRunner, settings.BattlesPerPair);
            var httpServer           = new GameHttpServer(httpListenerPrefix, arenaState, sessionManager, debuggerManager, tournamentRunner, staticContentPath);

            Runtime.SetStopHandler(() =>
            {
                log.InfoFormat("Stopping...");
                httpServer.Stop();
                tournamentRunner.Stop();
            });
            tournamentRunner.Start();
            httpServer.Run();
            log.InfoFormat("Listening on: {0}", httpListenerPrefix);
            if (!settings.ProductionMode)
            {
                Process.Start(httpServer.DefaultUrl);
            }
            httpServer.WaitForTermination();
            tournamentRunner.WaitForTermination();
            log.InfoFormat("Stopped");
        }
コード例 #2
0
 // Use this for initialization
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     if (instance != this)
     {
         Destroy(this);
     }
     MoveHolder      = MoveCollector.GetComponent <MoveCollector>();
     EnemyMoveHolder = EnemyAI.GetComponent <EnemyAI>();
     button.SetActive(true);
     button2.SetActive(true);
 }
コード例 #3
0
        public void UberTournament()
        {
            var players = TestWarriors.GetBotFiles("warriors-ok").Concat(TestWarriors.GetBotFiles("warriors-vec")).Select(botFilename => new TournamentPlayer
            {
                Name    = Path.GetFileNameWithoutExtension(botFilename),
                Program = File.ReadAllText(botFilename),
                Version = 1,
            })
                          .ToArray();

            Log.For(this).InfoFormat("Number of players: {0}", players.Length);
            var battleRunner = new BattleRunner();
            var tournament   = new RoundRobinTournament(battleRunner, 1, "allBotsRanking", players, null, null, false);
            var result       = tournament.Run();

            File.WriteAllText(@"all-bots-ranking.json", JsonConvert.SerializeObject(result.TournamentRanking, Formatting.Indented));
        }