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); }
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); } } }
public override bool CanExecute(IWorldModel worldModel) { int xp = (int)worldModel.GetProperty(Properties.XP); int level = (int)worldModel.GetProperty(Properties.LEVEL); return(xp >= level * 10); }
public void Initialize() { Model = new WorldModel(); Model.Data = 1; _scripts = new ArrayList(); Controller.Metaverse.RegisterMetaverseServer(this); }
public override bool CanExecute(IWorldModel worldModel) { if (!base.CanExecute(worldModel)) { return(false); } return(true); }
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)); }
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); }
public override bool CanExecute(IWorldModel worldModel) { if (this.Target == null) { return(false); } var targetEnabled = (bool)worldModel.GetProperty(this.Target.name); return(targetEnabled); }
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); }
public override bool CanExecute(IWorldModel worldModel) { if (!base.CanExecute(worldModel)) { return(false); } var mana = (int)worldModel.GetProperty(Properties.MANA); return(mana < 10); }
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"; }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
//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); }
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); } }
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); }
//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); }
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); }
public void Initialize() { Model = new WorldModel(); Model.Data = 1; _scripts = new ArrayList(); Controller.Metaverse.RegisterMetaverseServer( this ); }
public void ConnectToWorld(DirectoryInfo worldDirectory) { IWorldModel = new WorldModel(Orchestrator.ConnectToWorld(worldDirectory)); }
public override float GetHValue(IWorldModel worldModel) { //this is OP return(200.0f); }