private void OnAnyEntityHealed(EntityHealedEventData data) { if (data.Healer != Owner || data.Healing.IsVampirism() || data.Healing.IsRegeneration()) { return; } Experience.Add(4); }
private void OnAnyBehaviourApplied(Behaviour behaviour) { if (!(behaviour is ShieldBehaviour) || behaviour.Caster != Owner) { return; } Experience.Add(4); }
private void OnAnyEntityDamaged(EntityDamagedEventData data) { if (data.Attacker != Owner || !data.Damage.IsWeapon()) { return; } if (WearingItemOfRequiredType().Count == 0) { return; } Experience.Add(1); }
private void OnAnyComponentInitialized(Component component) { if (!(component is SummonedComponent summoned) || component.gameObject.IsDummy()) { return; } if (summoned.Master != Owner) { return; } Experience.Add(8); }
private void OnAnyEntityDamaged(EntityDamagedEventData data) { if (data.Attacker != Owner || !data.Damage.IsMagic()) { return; } if (this.Data.DamageType != data.Damage.Type) { return; } Experience.Add(1); }
public void GainXp(Settlement.Settlement settlement, Model.Settler.Skill.Skill skill, int amount) { var before = SkillLevel(skill); if (Experience.ContainsKey(skill)) { Experience[skill] += amount; } else { Experience.Add(skill, amount); } if (before < SkillLevel(skill)) { settlement.MessageManager.TodaysMessages.Add(new SkillIncreasedMessage(this, skill, SkillLevel(skill))); } }
public void Learn(double reward) { // perform an update on Q function if (rewardCache != 0 && Options.Alpha > 0) { // learn from this tuple to get a sense of how "surprising" it is to the agent var tderror = LearnFromTuple(previousStateCache, previousAction, rewardCache, nextStateCache); CurrentError = tderror; // a measure of surprise // decide if we should keep this experience in the replay if (learnLoopCount % Options.ExperienceAddEvery == 0) { var exp = new Experience { PreviousAction = previousAction, NextAction = nextAction, Reward = rewardCache, PreviousState = previousStateCache, NextState = nextStateCache }; Experience.Add(exp); if (Experience.Count > Options.ExperienceSize) { Experience.RemoveAt(0); } } learnLoopCount += 1; // sample some additional experience from replay memory and learn from it for (var k = 0; k < Options.LearningSteps; k++) { var ri = Util.Random(0, Experience.Count); var e = Experience[ri]; LearnFromTuple(e.PreviousState, e.PreviousAction, e.Reward, e.NextState); } } rewardCache = reward; // store for next update }
protected void getCompleteProfile(int in_current_userId, int in_profileId) { connect.Open(); SqlCommand cmd = connect.CreateCommand(); try { cmd.CommandText = "select physicianCompleteProfileId from PhysicianCompleteProfiles where userId = '" + in_profileId + "' "; ID = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select [physicianCompleteProfile_isPrivate] from PhysicianCompleteProfiles where userId = '" + in_profileId + "' "; Private = Convert.ToInt32(cmd.ExecuteScalar()); if (in_current_userId == in_profileId || Private == 0)//If the user trying access the profile is the owner { cmd.CommandText = "select [physicianCompleteProfile_Dialysis] from [PhysicianCompleteProfiles] where userId = '" + in_profileId + "' "; Dialysis = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select [physicianCompleteProfile_homeDialysis] from [PhysicianCompleteProfiles] where userId = '" + in_profileId + "' "; HomeDialysis = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select [physicianCompleteProfile_transplantation] from [PhysicianCompleteProfiles] where userId = '" + in_profileId + "' "; Transplantation = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select [physicianCompleteProfile_hypertension] from [PhysicianCompleteProfiles] where userId = '" + in_profileId + "' "; Hypertension = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select [physicianCompleteProfile_GN] from [PhysicianCompleteProfiles] where userId = '" + in_profileId + "' "; GN = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select [physicianCompleteProfile_physicianId] from [PhysicianCompleteProfiles] where userId = '" + in_profileId + "' "; PhysicianID = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select count(*) from PhysicianExperiences where physicianCompleteProfileId = '" + ID + "' "; int experiencesCount = Convert.ToInt32(cmd.ExecuteScalar()); if (experiencesCount > 0) { Experience = new List <string[]>(); } for (int i = 1; i <= experiencesCount; i++) { cmd.CommandText = "select physicianExperienceId from(SELECT rowNum = ROW_NUMBER() OVER(ORDER BY physicianExperienceId ASC), * FROM PhysicianExperiences where physicianCompleteProfileId = '" + ID + "') as t where rowNum = '" + i + "'"; string experienceId = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select physicianExperience_hospitalName from PhysicianExperiences where physicianExperienceId = '" + experienceId + "' "; string hospitalName = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select physicianExperience_hospitalAddress from PhysicianExperiences where physicianExperienceId = '" + experienceId + "' "; string hospitalAddress = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select physicianExperience_fromYear from PhysicianExperiences where physicianExperienceId = '" + experienceId + "' "; string fromYear = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select physicianExperience_toYear from PhysicianExperiences where physicianExperienceId = '" + experienceId + "' "; string toYear = cmd.ExecuteScalar().ToString(); string[] result = new string[] { hospitalName, hospitalAddress, fromYear, toYear }; Experience.Add(result); } } else //if (Private == 1) if the account is set to private and the user accessing it is not the owner: { //If the account is private or the user trying to access is not the owner, show nothing: Dialysis = ""; HomeDialysis = ""; Transplantation = ""; Hypertension = ""; GN = ""; PhysicianID = ""; if (Experience != null) { Experience.Clear(); } } } catch (Exception e) { Console.WriteLine("An error occured while trying to retrieve the Physician Complete Profile ID (" + ID + "): ", e); //If there is an error, set everything to blank to avoid null values: Dialysis = ""; HomeDialysis = ""; Transplantation = ""; Hypertension = ""; GN = ""; PhysicianID = ""; if (Experience != null) { Experience.Clear(); } } connect.Close(); }