Example #1
0
 public void CheckForDeath()
 {
     if (hp <= 0)
     {
         Singletons.GetPrinter().GameOver();
     }
 }
Example #2
0
        private AI_DFS_Decision MakeDecision_Using_Hand(AI_DFS_Decision previousState)
        {
            AI_DFS_Decision bestDecisiion = previousState;

            for (int i = 0; i < previousState.GetBoard().GetPlayer(playerNr).GetValidHandOptions().Count; i++)
            {
                BoardState       newBoard       = previousState.GetBoard().Copy();
                PlayerBoardState newPlayerState = newBoard.GetPlayer(playerNr);
                List <ICard>     options        = newPlayerState.GetValidHandOptions();

                ICard actionCard = options[i];

                Singletons.GetPrinter().AI_PlayCard(newPlayerState.playerSetup, actionCard, newPlayerState.GetManaLeft(), actionCard.GetCost());
                newPlayerState.SpendMana(actionCard);

                actionCard.PlayCard();
                AI_DFS_Decision exhaustedDecision = MakeDecision(new AI_DFS_Decision(newBoard, GetBoardStateAsValue(newBoard)));

                if (bestDecisiion.GetValue() < exhaustedDecision.GetValue())
                {
                    bestDecisiion = exhaustedDecision;
                }
            }

            return(bestDecisiion);
            //BATTLECRY NOT IMPLEMENTED YET!
            //if (actionCard.BattlecryRequiresTarget())
            //{
            //    List<ICard> possibleTargets = actionCard.GetBattlecryTargets();
            //    actionCard.SetBattlecryTarget(possibleTargets[random.Next(0, possibleTargets.Count)]);
            //}
        }
Example #3
0
        static void Main(string[] args)
        {
            SimulationResults results = RunSimulation(SetupData.GetTestJakob());

            //Print results
            Singletons.GetPrinter().AddEmptySpaces(2);
            PrintResults(results);
        }
Example #4
0
        //IAI_Guess_DecisionType
        public void Play(BoardState board, PlayerBoardState playerState)
        {
            if (actionCard.BattlecryRequiresTarget())
            {
                List <ICard> possibleTargets = actionCard.GetBattlecryTargets();
                actionCard.SetBattlecryTarget(possibleTargets[random.Next(0, possibleTargets.Count)]);
            }

            Singletons.GetPrinter().PlayCard(playerState.playerSetup, actionCard, playerState.GetManaLeft(), actionCard.GetCost());
            playerState.SpendMana(actionCard);
            actionCard.PlayCard();

            board.statisticResult.GetCardPlaySequence(playerState.GetPlayerNr()).Add(((ITrackable)actionCard).GetTemplate());
        }
Example #5
0
        private AI_DFS_Decision MakeDecision_Using_Board(AI_DFS_Decision previousState)
        {
            AI_DFS_Decision bestDecision = previousState;

            for (int i = 0; i < previousState.GetPlayerState(playerNr).GetValidBoardOptions().Count; i++)
            {
                //No need for duplicating the board yet, as we are only getting possible targets
                List <ICard>   originalOptions       = previousState.GetPlayerState(playerNr).GetValidBoardOptions();
                List <ITarget> originalTargetOptions = originalOptions[i].GetAttackTargetOptions(previousState.GetBoard());
                for (int y = 0; y < originalTargetOptions.Count; y++)
                {
                    BoardState       newBoard       = previousState.GetBoard().Copy();
                    PlayerBoardState newPlayerState = newBoard.GetPlayer(playerNr);
                    ICard            actionCard     = newPlayerState.GetValidBoardOptions()[i];
                    ITarget          target         = actionCard.GetAttackTargetOptions(newBoard)[y];

                    Singletons.GetPrinter().AI_AttackCard(actionCard, target);

                    if (target.GetOwner() == actionCard.GetOwner())
                    {
                        throw new Exception("ATTACKING MY OWN UNITS!?");
                    }

                    actionCard.Attack(target);
                    AI_DFS_Decision exhaustedDecision = MakeDecision(new AI_DFS_Decision(newBoard, GetBoardStateAsValue(newBoard)));

                    if (bestDecision.GetValue() < exhaustedDecision.GetValue())
                    {
                        bestDecision = exhaustedDecision;
                    }
                }
            }
            return(bestDecision);

            //List<ICard> options = playerState.GetValidBoardOptions();
            //ICard actionCard = options[random.Next(0, options.Count)];

            //List<ITarget> targetOptions = actionCard.GetAttackTargetOptions(state);
            //ITarget target = targetOptions[random.Next(0, targetOptions.Count)];

            //Singletons.GetPrinter().AttackCard(actionCard, target);


            //if (target.GetOwner() == actionCard.GetOwner())
            //    throw new Exception("ATTACKING MY OWN UNITS!?");

            //actionCard.Attack(target);
        }
Example #6
0
        public MatchResult PlayGame(PlayerSetup p1, Deck deck1, PlayerSetup p2, Deck deck2, int startCards)
        {
            BoardState board = new BoardState(p1, deck1, p2, deck2, startCards);

            currentPlayer = board.GetPlayerNumberGoingFirst();
            players[0].SetPlayer(playerNr.Player1);
            players[1].SetPlayer(playerNr.Player2);
            while (!board.isFinished)
            {
                currentPlayer++;
                currentPlayer = currentPlayer % players.Count;
                Singletons.GetPrinter().PlayerTurn(board.GetPlayer((playerNr)currentPlayer).playerSetup.name);
                players[currentPlayer].TakeTurn(board, (playerNr)currentPlayer);
            }
            return(board.statisticResult);
        }
Example #7
0
        private void MakeDecision_CardPool_Hand(BoardState state)
        {
            List <ICard> options    = GetPlayer(state).GetValidHandOptions();
            ICard        actionCard = options[random.Next(0, options.Count)];

            if (actionCard.BattlecryRequiresTarget())
            {
                List <ICard> possibleTargets = actionCard.GetBattlecryTargets();
                actionCard.SetBattlecryTarget(possibleTargets[random.Next(0, possibleTargets.Count)]);
            }

            Singletons.GetPrinter().PlayCard(GetPlayer(state).playerSetup, actionCard, GetPlayer(state).GetManaLeft(), actionCard.GetCost());
            GetPlayer(state).SpendMana(actionCard);

            actionCard.PlayCard();
        }
Example #8
0
        private void MakeDecision_CardPool_Board(BoardState state)
        {
            List <ICard> options    = GetPlayer(state).GetValidBoardOptions();
            ICard        actionCard = options[random.Next(0, options.Count)];

            List <ITarget> targetOptions = actionCard.GetAttackTargetOptions(state);
            ITarget        target        = targetOptions[random.Next(0, targetOptions.Count)];

            Singletons.GetPrinter().AttackCard(actionCard, target);


            if (target.GetOwner() == actionCard.GetOwner())
            {
                throw new Exception("ATTACKING MY OWN UNITS!?");
            }

            actionCard.Attack(target);
        }
Example #9
0
 /// <summary>
 /// Used for creating the original player
 /// </summary>
 /// <param name="playerSetup"></param>
 /// <param name="isGoingFirst"></param>
 /// <param name="deck"></param>
 /// <param name="board"></param>
 /// <param name="playerNr"></param>
 public PlayerBoardState(PlayerSetup playerSetup, bool isGoingFirst, Deck deck, BoardState board, playerNr playerNr, int StartCards)
 {
     startCards       = StartCards;
     this.playerNr    = playerNr;
     Hero             = new Hero(board, this);
     this.board       = board;
     this.playerSetup = playerSetup;
     myDeck           = deck.GetCardList(board, this);
     templateDeck     = deck;
     myHand           = new List <ICard>();
     myBoard          = new List <ICard>();
     myBoardWithTaunt = new List <ICard>();
     if (!isGoingFirst)
     {
         this.startCards++;
     }
     for (int i = 0; i < startCards; i++)
     {
         DrawCard();
     }
     Singletons.GetPrinter().StartCards(playerSetup, startCards, isGoingFirst, myHand);
 }
Example #10
0
 public void Damage(int dmg, string damageReason)
 {
     Singletons.GetPrinter().HeroDamaged(player.playerSetup, hp, dmg, damageReason);
     hp -= dmg;
 }
Example #11
0
 public void Damage(int dmg, string logDescription)
 {
     Singletons.GetPrinter().CardAttackTrade(player.playerSetup, this, GetHpLeft(), dmg);
     SetHpLeft(GetHpLeft() - dmg);
     CheckForDeath();
 }