Run() public method

public Run ( String folderPath ) : GameResult
folderPath String
return GameResult
Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var playerAPath = args[0];
            var playerABot = args[1];
            var playerBPath = args[2];
            var playerBBot = args[3];

            var playerA = new Player("botB", playerBPath, playerBBot, 'B');
            var playerB = new Player("botA", playerAPath, playerABot, 'A');
            var game = new Game(playerA, playerB, Properties.Settings.Default.SettingInitialMazeFilePath);
            game.Run("Match-" + DateTime.UtcNow.ToString("yyyy-MM-dd hh-mm-ss"));
        }
        static int Main(string[] args)
        {
            args = args ?? new string[] { };

            if (args.Any(x => helpOptions.Contains(x)) || args.Length != 4)
            {
                PrintUsage();
                return 1;
            }

            ShowArguments(args);

            var playerAPath = args[0];
            var playerABot = args[1];
            var playerBPath = args[2];
            var playerBBot = args[3];

            if (!Directory.Exists(playerAPath))
            {
                Console.WriteLine("error: <adir> '{0}' does not exist or is not a directory", playerAPath);
                return 1;
            }

            if (!File.Exists(Path.Combine(playerAPath, playerABot)))
            {
                Console.WriteLine("error: <abot> '{0}' does not exist inside <adir> or is not a file", playerABot);
                return 1;
            }

            if (!Directory.Exists(playerBPath))
            {
                Console.WriteLine("error: <bdir> '{0}' does not exist or is not a directory", playerBPath);
                return 1;
            }

            if (!File.Exists(Path.Combine(playerBPath, playerBBot)))
            {
                Console.WriteLine("error: <bbot> '{0}' does not exist inside <bdir> or is not a file", playerBBot);
                return 1;
            }

            var games = new List<GameResult>();

            Player playerA;
            Player playerB;

            var random = new Random();
            var randomPlayer = random.Next(1, 3);
            if (randomPlayer == 1)
            {
                playerA = new Player("botA", playerBPath, playerBBot, 'A');
                playerB = new Player("botB", playerAPath, playerABot, 'B');
            }
            else
            {
                playerA = new Player("botA", playerAPath, playerABot, 'A');
                playerB = new Player("botB", playerBPath, playerBBot, 'B');
            }

            var game = new Game(playerA, playerB, Properties.Settings.Default.SettingInitialMazeFilePath);
            var result = game.Run("Match_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
            games.Add(result);

            GameSummary(games);
            return 0;
        }