Ejemplo n.º 1
0
        public override bool CanExecute(IWorldModel worldModel)
        {
            int xp    = (int)worldModel.GetProperty(Properties.XP);
            int level = (int)worldModel.GetProperty(Properties.LEVEL);

            return(xp >= level * 10);
        }
Ejemplo n.º 2
0
        public override float GetHValue(IWorldModel worldModel)
        {
            float distance      = Vector3.Distance(Character.transform.position, Target.transform.position);
            float distanceBonus = 10.0f - (float)((distance * 10.0f) / 530);

            int mana  = (int)worldModel.GetProperty(Properties.MANA);
            int level = (int)worldModel.GetProperty(Properties.LEVEL);

            if (level == 3)
            {
                if (mana < 9)
                {
                    return(100.0f + distanceBonus);
                }
                else
                {
                    return(0.0f);
                }
            }
            else
            {
                if (mana < 2)
                {
                    return(100.0f + distanceBonus);
                }
                else
                {
                    return(0.0f);
                }
            }
        }
Ejemplo n.º 3
0
        public override float GetHValue(IWorldModel worldModel)
        {
            int hp    = (int)worldModel.GetProperty(Properties.HP);
            int maxhp = (int)worldModel.GetProperty(Properties.MAXHP);

            // 0 a 60
            return(60.0f - (float)((hp * 60) / maxhp));
        }
Ejemplo n.º 4
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            int maxHP = (int)worldModel.GetProperty(Properties.MAXHP);
            int level = (int)worldModel.GetProperty(Properties.LEVEL);

            worldModel.SetProperty(Properties.LEVEL, level + 1);
            worldModel.SetProperty(Properties.MAXHP, maxHP + 10);
            worldModel.SetProperty(Properties.XP, (int)0);
        }
Ejemplo n.º 5
0
        public override float GetHValue(IWorldModel worldModel)
        {
            float distance      = Vector3.Distance(Character.transform.position, Target.transform.position);
            float distanceBonus = 10.0f - (float)((distance * 10.0f) / 530);

            int hp    = (int)worldModel.GetProperty(Properties.HP);
            int maxhp = (int)worldModel.GetProperty(Properties.MAXHP);

            // 0 a 100
            return(100.0f - (float)((hp * 100) / maxhp) + distanceBonus);
        }
Ejemplo n.º 6
0
        public override bool CanExecute(IWorldModel worldModel)
        {
            if (!base.CanExecute(worldModel))
            {
                return(false);
            }

            var mana  = (int)worldModel.GetProperty(Properties.MANA);
            var level = (int)worldModel.GetProperty(Properties.LEVEL);

            return(mana >= 10 && level >= 3);
        }
Ejemplo n.º 7
0
        public override bool CanExecute(IWorldModel worldModel)
        {
            if (!base.CanExecute(worldModel))
            {
                return(false);
            }

            var hp    = (int)worldModel.GetProperty(Properties.HP);
            var maxHp = (int)worldModel.GetProperty(Properties.MAXHP);

            return(hp < maxHp);
        }
Ejemplo n.º 8
0
        public override bool CanExecute(IWorldModel worldModel)
        {
            if (!base.CanExecute(worldModel))
            {
                return(false);
            }

            var mana   = (int)worldModel.GetProperty(Properties.MANA);
            var shield = (int)worldModel.GetProperty(Properties.SHIELDHP);

            return(mana >= 5 && shield < 5);
        }
Ejemplo n.º 9
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            base.ApplyActionEffects(worldModel);

            var surviveValue = worldModel.GetGoalValue(AutonomousCharacter.SURVIVE_GOAL);

            worldModel.SetGoalValue(AutonomousCharacter.SURVIVE_GOAL, surviveValue - this.hpChange);

            var hp = (int)worldModel.GetProperty(Properties.MAXHP);

            worldModel.SetProperty(Properties.HP, hp);

            var mana = (int)worldModel.GetProperty(Properties.MANA);

            worldModel.SetProperty(Properties.MANA, mana - 7);
        }
Ejemplo n.º 10
0
        public override float GetHValue(IWorldModel worldModel)
        {
            float distance      = Vector3.Distance(Character.transform.position, Target.transform.position);
            float distanceBonus = 10.0f - (float)((distance * 10.0f) / 530);

            int level = (int)worldModel.GetProperty(Properties.LEVEL);

            if (level == 3)
            {
                return(0.0f);
            }

            else if (level == 2)
            {
                if (Target.tag.Equals("Skeleton") && (int)worldModel.GetProperty(Properties.MANA) < 2)
                {
                    return(50.0f + distanceBonus);
                }
                else if (Target.tag.Equals("Orc"))
                {
                    return(20.0f + distanceBonus);
                }
                else if (Target.tag.Equals("Dragon"))
                {
                    return(0.0f);
                }
            }
            else
            {
                if (Target.tag.Equals("Skeleton") && (int)worldModel.GetProperty(Properties.MANA) < 2)
                {
                    return(30.0f + distanceBonus);
                }
                else if (Target.tag.Equals("Orc"))
                {
                    return(0.0f);
                }
                else if (Target.tag.Equals("Dragon"))
                {
                    return(0.0f);
                }
            }
            return(0.0f);
        }
Ejemplo n.º 11
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            base.ApplyActionEffects(worldModel);

            var xpValue = worldModel.GetGoalValue(AutonomousCharacter.GAIN_XP_GOAL);

            worldModel.SetGoalValue(AutonomousCharacter.GAIN_XP_GOAL, xpValue - this.xpChange);

            var xp = (int)worldModel.GetProperty(Properties.XP);

            worldModel.SetProperty(Properties.XP, xp + this.xpChange);

            var mana = (int)worldModel.GetProperty(Properties.MANA);

            worldModel.SetProperty(Properties.MANA, mana - 2);

            //disables the target object so that it can't be reused again
            worldModel.SetProperty(this.Target.name, false);
        }
Ejemplo n.º 12
0
        public override bool CanExecute(IWorldModel worldModel)
        {
            if (this.Target == null)
            {
                return(false);
            }
            var targetEnabled = (bool)worldModel.GetProperty(this.Target.name);

            return(targetEnabled);
        }
Ejemplo n.º 13
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            base.ApplyActionEffects(worldModel);

            int hp       = (int)worldModel.GetProperty(Properties.HP);
            int shieldHp = (int)worldModel.GetProperty(Properties.SHIELDHP);
            int xp       = (int)worldModel.GetProperty(Properties.XP);
            //execute the lambda function to calculate received damage based on the creature type
            int damage = this.dmgRoll.Invoke();

            //calculate player's damage
            int remainingDamage = damage - shieldHp;
            int remainingShield = Mathf.Max(0, shieldHp - damage);
            int remainingHP;

            if (remainingDamage > 0)
            {
                remainingHP = hp - remainingDamage;
                worldModel.SetProperty(Properties.HP, remainingHP);
            }

            worldModel.SetProperty(Properties.SHIELDHP, remainingShield);
            var surviveValue = worldModel.GetGoalValue(AutonomousCharacter.SURVIVE_GOAL);

            worldModel.SetGoalValue(AutonomousCharacter.SURVIVE_GOAL, surviveValue - remainingDamage);


            //calculate Hit
            //attack roll = D20 + attack modifier. Using 7 as attack modifier (+4 str modifier, +3 proficiency bonus)
            int attackRoll = RandomHelper.RollD20() + 7;

            if (attackRoll >= enemyAC)
            {
                //there was an hit, enemy is destroyed, gain xp
                //disables the target object so that it can't be reused again
                worldModel.SetProperty(this.Target.name, false);

                worldModel.SetProperty(Properties.XP, xp + this.xpChange);
                var xpValue = worldModel.GetGoalValue(AutonomousCharacter.GAIN_XP_GOAL);
                worldModel.SetGoalValue(AutonomousCharacter.GAIN_XP_GOAL, xpValue - this.xpChange);
            }
        }
Ejemplo n.º 14
0
        public override bool CanExecute(IWorldModel worldModel)
        {
            if (!base.CanExecute(worldModel))
            {
                return(false);
            }

            var mana = (int)worldModel.GetProperty(Properties.MANA);

            return(mana < 10);
        }
Ejemplo n.º 15
0
        public override float GetHValue(IWorldModel worldModel)
        {
            float distance      = Vector3.Distance(Character.transform.position, Target.transform.position);
            float distanceBonus = 10.0f - (float)((distance * 10.0f) / 530);

            int level = (int)worldModel.GetProperty(Properties.LEVEL);

            //if (level == 1)
            return(100.0f + distanceBonus * 3);

            //else
            return(0.0f);
        }
Ejemplo n.º 16
0
        public override float GetHValue(IWorldModel worldModel)
        {
            float distance = Vector3.Distance(Character.transform.position, Target.transform.position);

            if (distance < 20.0f)
            {
                return(200.0f);
            }
            float distanceBonus = 10.0f - (float)((distance * 10.0f) / 530);
            int   level         = (int)worldModel.GetProperty(Properties.LEVEL);

            // level 1 = 25, level 2 = 50, level 3 = 75
            return((level * 25.0f) + distanceBonus);
        }
Ejemplo n.º 17
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            var duration = this.GetDuration(worldModel);

            var quicknessValue = worldModel.GetGoalValue(AutonomousCharacter.BE_QUICK_GOAL);

            worldModel.SetGoalValue(AutonomousCharacter.BE_QUICK_GOAL, quicknessValue + duration * 0.1f);

            var time = (float)worldModel.GetProperty(Properties.TIME);

            worldModel.SetProperty(Properties.TIME, time + duration);

            worldModel.SetProperty(Properties.POSITION, Target.transform.position);
        }
Ejemplo n.º 18
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            base.ApplyActionEffects(worldModel);

            var goalValue = worldModel.GetGoalValue(AutonomousCharacter.GET_RICH_GOAL);

            worldModel.SetGoalValue(AutonomousCharacter.GET_RICH_GOAL, goalValue - 5.0f);

            var money = (int)worldModel.GetProperty(Properties.MONEY);

            worldModel.SetProperty(Properties.MONEY, money + 5);

            //disables the target object so that it can't be reused again
            worldModel.SetProperty(this.Target.name, false);
        }
Ejemplo n.º 19
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            base.ApplyActionEffects(worldModel);

            var surviveValue = worldModel.GetGoalValue(AutonomousCharacter.SURVIVE_GOAL);

            worldModel.SetGoalValue(AutonomousCharacter.SURVIVE_GOAL, surviveValue - this.hpChange);


            var hp = (int)worldModel.GetProperty(Properties.MAXHP);

            worldModel.SetProperty(Properties.HP, hp);
            //disables the target object so that it can't be reused again
            worldModel.SetProperty(this.Target.name, false);
        }
Ejemplo n.º 20
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            base.ApplyActionEffects(worldModel);

            var goalValue = worldModel.GetGoalValue(AutonomousCharacter.GET_RICH_GOAL);

            worldModel.SetGoalValue(AutonomousCharacter.GET_RICH_GOAL, goalValue - 5.0f);

            var mana = (int)worldModel.GetProperty(Properties.MANA);

            worldModel.SetProperty(Properties.MANA, mana - 10);

            for (int i = 0; i < 7; i++)
            {
                worldModel.SetProperty("Skeleton" + i, false);
            }
            for (int i = 0; i < 2; i++)
            {
                worldModel.SetProperty("Orc" + i, false);
            }
            worldModel.SetProperty("Dragon", false);
        }
Ejemplo n.º 21
0
        public Reward(IWorldModel world, int player)
        {
            this.PlayerID       = player;
            this.hp             = (int)world.GetProperty(Properties.HP);
            this.xp             = (int)world.GetProperty(Properties.LEVEL);
            this.maxhp          = (int)world.GetProperty(Properties.MAXHP);
            this.coinsCollected = (int)world.GetProperty(Properties.MONEY);
            this.time           = (float)world.GetProperty(Properties.TIME);
            this.shieldhp       = (int)world.GetProperty(Properties.SHIELDHP);

            for (int i = 1; i <= 2; i++)
            {
                if (!(bool)world.GetProperty("ManaPotion" + i))
                {
                    resourcesConsumed++;
                }
            }
            for (int i = 1; i <= 2; i++)
            {
                if (!(bool)world.GetProperty("HealthPotion" + i))
                {
                    resourcesConsumed++;
                }
            }
            for (int i = 1; i <= 7; i++)
            {
                if (!(bool)world.GetProperty("Skeleton" + i))
                {
                    enemiesKilled++;
                }
            }
            for (int i = 1; i <= 2; i++)
            {
                if (!(bool)world.GetProperty("Orc" + i))
                {
                    enemiesKilled++;
                }
            }
            if (!(bool)world.GetProperty("Dragon"))
            {
                enemiesKilled++;
            }

            //Normalize the values

            this.resourcesConsumed = (4 - resourcesConsumed) / 4;
            this.hp             = hp / 30;
            this.xp             = (xp - 1) / 2;
            this.enemiesKilled  = enemiesKilled / 10;
            this.coinsCollected = coinsCollected / 25;
            this.time           = 1 - (time / 200);
            if (this.xp > 0)
            {
                this.shieldhp = shieldhp / 5f;
            }
            else
            {
                this.shieldhp = 0;
            }


            //BIAS Continuous
            Value = xp * 0.2f + hp * 0.40f + enemiesKilled * 0.3f + resourcesConsumed * 0.1f + time * 0.1f;

            //NO BIAS Continous
            //Value = xp * 0.1f + hp * 0.60f + enemiesKilled * 0.2f + resourcesConsumed * 0.0f + time * 0.1f;

            //FLAT REWARD
            //Value = world.GetScore();
        }
Ejemplo n.º 22
0
        public override float GetDuration(IWorldModel worldModel)
        {
            var position = (Vector3)worldModel.GetProperty(Properties.POSITION);

            return(this.GetDuration(position));
        }