Exemple #1
0
        private AI_Guess_Decision MakeDecision_Using_Board(AI_Guess_Decision previousState)
        {
            AI_Guess_Decision bestDecision  = new AI_Guess_Decision(previousState.GetBoard(), previousState.GetBoardValue());
            PlayerBoardState  playerState   = previousState.GetBoard().GetPlayer(playerNr);
            List <ICard>      myUnitOptions = previousState.GetPlayerState(playerNr).GetValidBoardOptions();

            for (int i = 0; i < previousState.GetPlayerState(playerNr).GetValidBoardOptions().Count; i++)
            {
                ICard actionCard = playerState.GetValidBoardOptions()[i];
                if (playerState.opponent.GetTauntBoard().Count > 0 || IsDyingFirst(playerState)) //Trade
                {
                    List <ITarget> originalTargetOptions = actionCard.GetAttackTargetOptions(previousState.GetBoard());
                    for (int y = 0; y < originalTargetOptions.Count; y++)
                    {
                        ITarget target = originalTargetOptions[y];

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

                        double val = evalutator.TradeOnBoard(actionCard, target, playerState, previousState.GetBoard());
                        if (bestDecision.GetBoardValue() < (previousState.GetBoardValue() + val))
                        {
                            bestDecision.SetBoardValue(previousState.GetBoardValue() + val);
                            bestDecision.SetDecision(new AI_Guess_Decision_Trade(actionCard, target));
                        }
                    }
                }
                else //Face
                {
                    var val = evalutator.FaceAttackOnBoard(actionCard, playerState.opponent.Hero, playerState, previousState.GetBoard());
                    if (bestDecision.GetBoardValue() < (previousState.GetBoardValue() + val))
                    {
                        bestDecision.SetBoardValue(previousState.GetBoardValue() + val);
                        bestDecision.SetDecision(new AI_Guess_Decision_Face(actionCard));
                        return(bestDecision);
                    }
                }
            }
            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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }