Beispiel #1
0
        private static bool CorrectForSummonAndEquip(Card card, TyState ownerState, TyState opponentState)
        {
            var  text    = card.Text;
            bool success = true;

            if (text.Contains("Equip"))
            {
                int dmg        = 0;
                int durability = 0;
                if (FindNumberValues(text, ref dmg, ref durability))
                {
                    EquipWeapon(ownerState, dmg, durability);
                    success = true;
                }
            }

            if (text.Contains("Summon"))
            {
                int dmg    = 0;
                int health = 0;
                if (FindNumberValues(text, ref dmg, ref health))
                {
                    ownerState.MinionValues += TyMinionUtil.ComputeMinionValue(health, dmg, 1);
                    //just assume that the minion has some sort of (unknown) ability:
                    //Testing.TyDebug.LogInfo("Summoned " + dmg + "/" + health);
                    ownerState.MinionValues += 3;
                    success = true;
                }
            }

            return(success);
        }
        //After your opponent plays a minion, summon a copy of it.
        private static void MirrorEntity(TyState playerState, TyState opponentState, Controller player, Controller opponent, Spell secret)
        {
            var mana   = opponent.GetAvailableMana();
            var minion = TyMinionUtil.EstimatedValueFromMana(mana);

            playerState.BiasValue    += TyStateUtility.LateReward(mana, 4, 5.0f);
            playerState.MinionValues += minion;
        }
        //After your opponent plays a minion, add two copies of it to_your hand.
        private static void FrozenClone(TyState playerState, TyState opponentState, Controller player, Controller opponent, Spell secret)
        {
            var mana   = opponent.GetAvailableMana();
            var minion = TyMinionUtil.EstimatedValueFromMana(mana);

            //dont multiply by 2, because player still has to play the minions:
            playerState.BiasValue += minion * 1.75f + TyStateUtility.LateReward(mana, 4, 4.0f);
        }
        //When an enemy casts a spell on a minion, summon a 1/3 as the new target.
        private static void Spellbender(TyState playerState, TyState opponentState, Controller player, Controller opponent, Spell secret)
        {
            var myMana = player.GetAvailableMana();
            var possibleAverageMinion = TyMinionUtil.EstimatedValueFromMana(myMana);
            var myAverageMinion       = playerState.GetAverageMinionValue();

            //dont play if my minions are weaker than a "good" minion at that point in game, also punish when played early:
            playerState.BiasValue += (myAverageMinion - possibleAverageMinion) + TyStateUtility.LateReward(myMana, 4, 2.0f);
        }
        //When a minion attacks your hero, destroy it.
        private static void Vaporize(TyState playerState, TyState opponentState, Controller player, Controller opponent, Spell secret)
        {
            var opponentMana = opponent.GetAvailableMana();

            //punish playing early:
            playerState.BiasValue += TyStateUtility.LateReward(opponentMana, 5, 5.0f);

            //estimate destroying an enemy minion:
            float avgMinionValue = TyMinionUtil.EstimatedValueFromMana(opponentMana);

            opponentState.MinionValues -= avgMinionValue;
        }
Beispiel #6
0
        public static TyState FromSimulatedGame(POGame.POGame newState, Controller me, PlayerTask task)
        {
            TyState s = new TyState
            {
                HeroHealth = me.Hero.Health,
                HeroArmor  = me.Hero.Armor,

                TurnNumber = newState.Turn,

                NumDeckCards      = me.DeckZone.Count,
                NumHandCards      = me.HandZone.Count,
                NumMinionsOnBoard = me.BoardZone.Count,

                Fatigue      = me.Hero.Fatigue,
                MinionValues = TyMinionUtil.ComputeMinionValues(me)
            };

            if (me.Hero.Weapon != null)
            {
                s.WeaponDurability = me.Hero.Weapon.Durability;
                s.WeaponDamage     = me.Hero.Weapon.AttackDamage;
            }

            //this case is met, if the player uses a card that temporarily boosts attack:
            if (me.Hero.TotalAttackDamage > s.WeaponDamage)
            {
                s.WeaponDamage = me.Hero.TotalAttackDamage;

                //assume that the player can at least attack once:
                if (s.WeaponDurability == 0)
                {
                    s.WeaponDurability = 1;
                }
            }

            //aka, can't attack:
            if (me.Hero.IsFrozen)
            {
                s.WeaponDamage = 0;
            }

            var minion = task.TryGetMinion();

            if (minion != null)
            {
                //give reward/punishment of minions cost less/more than usual:
                float diff = (float)minion.Card.Cost - (float)minion.Cost;
                s.BiasValue += diff * 1.5f;
            }

            return(s);
        }
        //After your opponent plays a minion, transform it into a 1/1 Sheep.
        private static void PotionOfPolymorph(TyState playerState, TyState opponentState, Controller player, Controller opponent, Spell secret)
        {
            int opponentMana = opponent.GetAvailableMana();

            //punish playing early:
            playerState.BiasValue += TyStateUtility.LateReward(opponentMana, 5, 5.0f);

            //value is the difference between an average minion and the sheep:
            float sheepValue         = TyMinionUtil.ComputeMinionValue(1, 1, 1);
            float averageMinionValue = TyMinionUtil.EstimatedValueFromMana(opponentMana);
            float polymorphedValue   = (sheepValue - averageMinionValue);

            opponentState.MinionValues += polymorphedValue;
        }
Beispiel #8
0
        private static void RemoveMinion(Minion minion, TyState ownerState, TyState opponentState, PlayerTask task)
        {
            //remove the minion value from the overall minion values and remove it from the board
            ownerState.MinionValues -= TyMinionUtil.ComputeMinionValue(minion);
            ownerState.NumMinionsOnBoard--;

            if (minion.HasDeathrattle)
            {
                if (!CorrectForSummonAndEquip(minion.Card, ownerState, opponentState) && TyConst.LOG_UNKNOWN_CORRECTIONS)
                {
                    TyDebug.LogError("Unknown deathrattle from " + minion.Card.FullPrint());
                    TyDebug.LogWarning("After task " + task.FullPrint());
                }
            }
        }