예제 #1
0
 public override void ApplyActionEffects(IWorldModel worldModel)
 {
     base.ApplyActionEffects(worldModel);
     worldModel.SetProperty(Properties.MANA, 10);
     //disables the target object so that it can't be reused again
     worldModel.SetProperty(this.Target.name, false);
 }
예제 #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);
                }
            }
        }
예제 #3
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);
        }
예제 #4
0
 public void Initialize()
 {
     Model      = new WorldModel();
     Model.Data = 1;
     _scripts   = new ArrayList();
     Controller.Metaverse.RegisterMetaverseServer(this);
 }
예제 #5
0
 public override bool CanExecute(IWorldModel worldModel)
 {
     if (!base.CanExecute(worldModel))
     {
         return(false);
     }
     return(true);
 }
예제 #6
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));
        }
예제 #7
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);
        }
예제 #8
0
        public override bool CanExecute(IWorldModel worldModel)
        {
            if (this.Target == null)
            {
                return(false);
            }
            var targetEnabled = (bool)worldModel.GetProperty(this.Target.name);

            return(targetEnabled);
        }
예제 #9
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);
        }
예제 #10
0
        public override bool CanExecute(IWorldModel worldModel)
        {
            if (!base.CanExecute(worldModel))
            {
                return(false);
            }

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

            return(mana < 10);
        }
예제 #11
0
        public WorldPanelViewModel(MainModel worldModel)
        {
            m_IWorldModel = worldModel.IWorldModel;
            m_IWorldModel.PropertyChanged += WorldModel_PropertyChanged;
            BridgeBuilder.BuildBridge
                (worldModel.IWorldModel.IPortalModels,
                this.Portals,
                (model => new PortalViewModel(model)));

            Name = "Norntopia";
        }
예제 #12
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);
        }
예제 #13
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);
        }
예제 #14
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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #17
0
        public override void ApplyActionEffects(IWorldModel worldModel)
        {
            base.ApplyActionEffects(worldModel);

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

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

            worldModel.SetProperty(Properties.SHIELDHP, this.shieldChange);

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

            worldModel.SetProperty(Properties.MANA, mana - 5);
        }
예제 #18
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);
        }
예제 #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);
        }
예제 #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 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);
        }
예제 #21
0
        virtual protected Reward Playout(IWorldModel initialPlayoutState)
        {
            IWorldModel prevState = initialPlayoutState.GenerateChildWorldModel();

            CurrentDepth = 0;
            //Perform n playouts for each state [to deal with stochastic nature]
            while (!prevState.IsTerminal() && CurrentDepth < MaxPlayoutDepthAllowed)
            {
                GOB.Action[] actions      = prevState.GetExecutableActions();
                int          randomAction = RandomGenerator.Next(actions.Length);
                prevState = StochasticPlayout(actions[randomAction], prevState, MaxPlayoutSimulations);
                prevState.CalculateNextPlayer();
                CurrentDepth++;
            }
            Reward reward = new Reward(prevState, prevState.GetNextPlayer());

            return(reward);
        }
예제 #22
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);
        }
예제 #23
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);
        }
예제 #24
0
        //method to average out and apply the effects of a sword attack playout in a stochastic world
        private IWorldModel MergeStates(IWorldModel[] testStates, SwordAttack enemy)
        {
            int  hp             = 0;
            int  shieldHP       = 0;
            int  enemyDeadCount = 0;
            bool enemyAlive     = true;
            int  xp             = 0;
            int  n = testStates.Length;

            for (int i = 0; i < n; i++)
            {
                hp       += (int)testStates[i].GetProperty(Properties.HP);
                shieldHP += (int)testStates[i].GetProperty(Properties.SHIELDHP);
                if ((bool)testStates[i].GetProperty(enemy.Target.tag) != true)
                {
                    xp += (int)testStates[i].GetProperty(Properties.XP);
                    enemyDeadCount++;
                }
            }

            hp       = hp / n;
            shieldHP = shieldHP / n;

            if (enemyDeadCount > ((float)n / 2)) //enemy is dead on average, rounded up
            {
                xp         = xp / enemyDeadCount;
                enemyAlive = false;
            }
            else
            {
                xp = 0;
            }

            //returning the testState[0] as the resulting average
            IWorldModel returnState = testStates[0];

            returnState.SetProperty(Properties.HP, hp);
            returnState.SetProperty(Properties.SHIELDHP, shieldHP);
            returnState.SetProperty(enemy.Target.name, enemyAlive);
            returnState.SetProperty(Properties.XP, xp);
            return(returnState);
        }
예제 #25
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);
            }
        }
예제 #26
0
        protected override Reward Playout(IWorldModel initialPlayoutState)
        {
            IWorldModel state = initialPlayoutState.GenerateChildWorldModel();

            CurrentDepth = 0;
            while (!state.IsTerminal() && CurrentDepth < MaxPlayoutDepthAllowed)
            {
                List <KeyValuePair <int, GOB.Action> > actions = new List <KeyValuePair <int, GOB.Action> >();
                foreach (GOB.Action action in state.GetExecutableActions())
                {
                    actions.Add(new KeyValuePair <int, GOB.Action>((int)action.GetHValue(state), action));
                }
                actions.Sort(
                    delegate(KeyValuePair <int, GOB.Action> p1, KeyValuePair <int, GOB.Action> p2)
                {
                    return(p1.Key.CompareTo(p2.Key));
                }
                    );
                if (actions.Count == 0)
                {
                    break;
                }

                int randomValue = this.RandomGenerator.Next((int)actions[actions.Count - 1].Key);

                foreach (KeyValuePair <int, GOB.Action> pair in actions)
                {
                    if (pair.Key > randomValue)
                    {
                        state = StochasticPlayout(pair.Value, state, MaxPlayoutSimulations);
                        pair.Value.ApplyActionEffects(state);
                        break;
                    }
                }
                state.CalculateNextPlayer();
                CurrentDepth++;
            }

            Reward reward = new Reward(state, state.GetNextPlayer());

            return(reward);
        }
예제 #27
0
 //Simulates one or many playouts of an action in a state. Only applies to swordattack as all other actions are not stochastic.
 //Afterwards merges them in MergeStates to average out the results.
 protected IWorldModel StochasticPlayout(Action action, IWorldModel prevState, int n)
 {
     if (action.Name.Contains("SwordAttack") && n > 0)
     {
         IWorldModel[] testStates = new WorldModelFEAR[n];
         //IWorldModel[] testStates = new WorldModel[n];
         for (int i = 0; i < n; i++)
         {
             TotalPlayouts++;
             testStates[i] = prevState.GenerateChildWorldModel();
             action.ApplyActionEffects(testStates[i]);
         }
         prevState = MergeStates(testStates, (SwordAttack)action);
     }
     else
     {
         TotalPlayouts++;
         prevState = prevState.GenerateChildWorldModel();
         action.ApplyActionEffects(prevState);
     }
     return(prevState);
 }
예제 #28
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);
        }
예제 #29
0
 public void Initialize()
 {
     Model = new WorldModel();
     Model.Data = 1;
     _scripts = new ArrayList();
     Controller.Metaverse.RegisterMetaverseServer( this );
 }
예제 #30
0
 public void ConnectToWorld(DirectoryInfo worldDirectory)
 {
     IWorldModel = new WorldModel(Orchestrator.ConnectToWorld(worldDirectory));
 }
예제 #31
0
 public override float GetHValue(IWorldModel worldModel)
 {
     //this is OP
     return(200.0f);
 }