Exemplo n.º 1
0
        private static RoboPlayerPlugin SetupRoboPlayer(RoboManager roboManager, String kiExecutable, bool relative)
        {
            RoboPlayerPlugin roboPlugin = RoboUtils.RegisterPlugin(roboManager, kiExecutable, relative);

            roboManager.ActivatePlugin(roboPlugin);
            return(roboPlugin);
        }
Exemplo n.º 2
0
        // MonoRobots.exe --play <relative_ki> <relative_board> <difficulty?>
        private static void PlayGame(String kiPath, String boardPath, Difficulty difficulty)
        {
            RoboManager      roboManager = SetupRoboManager();
            RoboPlayerPlugin roboPlugin  = SetupRoboPlayer(roboManager, kiPath, true);
            RoboBoard        board       = RoboUtils.LoadBoard(boardPath, true, difficulty);

            Console.WriteLine("Start...");

            ExecuteGame(roboManager, board, RoboUtils.CreateCardPile());

            Console.Write(GetResults(roboManager));
            Console.WriteLine("End...");
        }
Exemplo n.º 3
0
        // MonoRobots.exe --deck <relative_directory> <no_of_decks?>
        private static void CreateDeck(String relativePath, int amount)
        {
            String finalPath = Directory.GetCurrentDirectory() + "/" + relativePath;

            if (!Directory.Exists(finalPath))
            {
                Directory.CreateDirectory(finalPath);
            }
            for (int i = 0; i < amount; ++i)
            {
                RoboCard[] cards = RoboUtils.CreateCardPile();
                RoboUtils.SaveCardsToFile(finalPath + "/cards" + (i + 1 + "").PadLeft((amount + "").Length, '0') + ".deck", cards);
            }
        }
Exemplo n.º 4
0
        private void DoPlayingCards()
        {
            if (GameState != RoboGameState.ChoosingCards || !IsChoosingCardsFinished)
            {
                return;
            }

            GameState = RoboGameState.PlayingCards;

            for (int i = 0; i < 5; i++)
            {
                foreach (RoboPlayerPlugin elem in ActivePlayers.OrderBy(elem => elem.Player.TimeEndRound.Ticks))
                {
                    if (elem.Player.PlayerState != RoboPlayerState.Decided)
                    {
                        continue;
                    }
                    RoboUtils.PlayCardCore(GetBoard(Board, elem.Player, ActivePlayers.Select(plugin => plugin.Player)), elem.Player.ChosenCards[i], elem.Player.Position);
                    elem.Player.TotalPlayedCards++;

                    if (Board.GetField(elem.Player.Position).IsDestination)
                    {
                        elem.Player.PlayerState = RoboPlayerState.Finished;
                    }
                    else if (elem.Player.Position.IsDead)
                    {
                        elem.Player.PlayerState = RoboPlayerState.Dead;
                    }
                    else if (i == 4)
                    {
                        elem.Player.PlayerState = RoboPlayerState.Ready;
                    }
                }
            }

            GameState = RoboGameState.Ready;

            Action starter = StartRound;

            starter.BeginInvoke(null, starter);
        }
Exemplo n.º 5
0
        // MonoRobots.exe --stats <relative_ki> <relative_boards> <relative_decks>
        private static void Statistics(String kiPath, String boardsPath, String decksPath, Difficulty difficulty)
        {
            RoboManager roboManager = SetupRoboManager();

            Dictionary <String, Dictionary <String, List <RoboPlayerResult> > > allResults = new Dictionary <String, Dictionary <String, List <RoboPlayerResult> > >();

            int roundsPlayedInTotal = 0;

            foreach (String boardFileName in getFileEnumerable(boardsPath))
            {
                RoboBoard board = RoboUtils.LoadBoard(boardFileName, true, difficulty);
                foreach (String pluginPath in getFileEnumerable(kiPath))
                {
                    RoboPlayerPlugin roboPlugin = SetupRoboPlayer(roboManager, pluginPath, true);

                    Dictionary <String, List <RoboPlayerResult> > boardResults = new Dictionary <String, List <RoboPlayerResult> >();
                    allResults[boardFileName] = boardResults;
                    List <RoboPlayerResult> playerResults = new List <RoboPlayerResult>();
                    boardResults.Add(pluginPath, playerResults);

                    foreach (String deckFileName in getFileEnumerable(decksPath))
                    {
                        RoboCard[] pile = RoboUtils.LoadCardDeck(deckFileName);
                        ExecuteGame(roboManager, board, pile);
                        roundsPlayedInTotal++;

                        RoboPlayerResult singleStat = new RoboPlayerResult(roboPlugin.Player);
                        playerResults.Add(singleStat);
                    }

                    roboManager.DeactivatePlugin(roboPlugin);
                }
            }

            Console.WriteLine("RoundsPlayed: " + roundsPlayedInTotal);
            Console.Write(GetFormattedStatistics(allResults));
        }
Exemplo n.º 6
0
 public void StartGame()
 {
     RoboCard[] pile = RoboUtils.CreateCardPile();
     StartGame(Board, pile);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Read in handcards.
 /// </summary>
 /// <param name="filename">Filename.</param>
 /// <returns>True on successfull load, false else.</returns>
 public void ReadCardsFromFile(String filename)
 {
     Cards = RoboUtils.LoadCards(filename, 8);
 }