public Consideration AddConsideration(IBlackboard bb) { var result = new Consideration(bb); considerations.Add(result); return(result); }
public void SetCurveValues(Consideration MyTarget, Consideration.CurveType CurveType, float Steepness, float yShift, float xShift) { MyTarget.TypeOfCurve = CurveType; MyTarget.Steepness = Steepness; MyTarget.yShift = yShift; MyTarget.xShift = xShift; }
private void RefreshConsiderationControls(Consideration editedConsideration) { ConsiderationsListView.Items.Clear(); if (BehaviorsListView.SelectedItems.Count <= 0) { return; } var behavior = BehaviorsListView.SelectedItems[0].Tag as Behavior; foreach (var consideration in behavior.Considerations) { var item = new ListViewItem(consideration.ReadableName) { Tag = consideration }; ConsiderationsListView.Items.Add(item); } if (editedConsideration != null) { foreach (ListViewItem item in ConsiderationsListView.Items) { if (item.Tag == editedConsideration) { ConsiderationsListView.SelectedIndices.Add(item.Index); break; } } } }
public async Task <IActionResult> PutConsideration([FromRoute] Guid id, [FromBody] Consideration consideration) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != consideration.ConsiderationId) { return(BadRequest()); } _context.Entry(consideration).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConsiderationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Create(ConsiderationViewModel consideration) { var conlist = new List <Consideration>(); if (ModelState.IsValid) { foreach (var condata in consideration.considerationList) { var con = new Consideration(); con.GeneralParcelId = consideration.GeneralParcelId; con.FactorValueId = condata.FactorValueId; var convalue = condata.Value; if (convalue != null) { con.Value = convalue.Value; } else { con.Value = 0; } con.Status = condata.Status; conlist.Add(con); } db.Considerations.AddRange(conlist); db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.FactorValueId = new SelectList(db.FactorValues, "id", "Name", consideration.FactorValueId); //ViewBag.GeneralParcelId = new SelectList(db.GeneralInfoParcels, "Id", "ParcelNo", consideration.GeneralParcelId); return(View(consideration)); }
protected override void RenderBody(SerializedPropertyX considerationProperty, RenderData _data, int index) { ConsiderationRenderData data = _data as ConsiderationRenderData; Consideration consideration = considerationProperty.GetValue <Consideration>(); //manually render description and curve to make sure they come first DrawerUtil.PushLabelWidth(125); DrawerUtil.PushIndentLevel(1); consideration.description = EditorGUILayout.TextField(new GUIContent("Description"), consideration.description); GUIContent content = new GUIContent(); content.text = Util.SplitAndTitlize(consideration.GetType().Name); EditorGUILayout.BeginHorizontal(); data.isInputDisplayed = EditorGUILayout.Foldout(data.isInputDisplayed, content); EditorGUILayout.EndHorizontal(); if (data.isInputDisplayed) { EditorGUI.indentLevel++; for (int i = 0; i < considerationProperty.ChildCount; i++) { SerializedPropertyX child = considerationProperty.GetChildAt(i); if (skipRenderingFields.IndexOf(child.name) != -1) { continue; } EditorGUILayoutX.PropertyField(child, child.label, child.isExpanded); } EditorGUI.indentLevel--; } RenderCurve(considerationProperty.FindProperty("curve"), data); DrawerUtil.PopLabelWidth(); DrawerUtil.PopIndentLevel(); }
public ActionResult DeleteConfirmed(int id) { Consideration consideration = db.Considerations.Find(id); db.Considerations.Remove(consideration); db.SaveChanges(); return(RedirectToAction("Index")); }
private float getScore(Consideration <T> consideration) { switch (scoreType) { case ScoreType.Raw: return(consideration.score()); case ScoreType.Normalized: return(consideration.normalizedScore()); } return(0); }
public async Task <IActionResult> PostConsideration([FromBody] Consideration consideration) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Consideration.Add(consideration); await _context.SaveChangesAsync(); return(CreatedAtAction("GetConsideration", new { id = consideration.ConsiderationId }, consideration)); }
public ActionResult Edit([Bind(Include = "Id,GeneralParcelId,FactorValueId,Status,Value")] Consideration consideration) { if (ModelState.IsValid) { db.Entry(consideration).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FactorValueId = new SelectList(db.FactorValues, "id", "Name", consideration.FactorValueId); ViewBag.GeneralParcelId = new SelectList(db.GeneralInfoParcels, "Id", "ParcelNo", consideration.GeneralParcelId); return(View(consideration)); }
public Consideration ConsiderQuestion(string TitleCode, int QuestionNumber, [FromBody] Consideration consideration) { var _consideration = new InActive.Consideration() { _id = repoForApprove.GetNewGuid("").ToString(), CreateDateTime = DateTime.Now, RejectComment = consideration?.RejectComment, IsAccept = consideration?.IsAccept ?? false, UserName = consideration?.UserName, //TODO : userName ?? ExamSuiteId = consideration.ExamSuiteId, QuestionNumber = QuestionNumber, }; var preConsiderationExamSuite = repoQ.GetQuestionSuite(consideration.ExamSuiteId); var preStatus = repoForApprove.GetConsiderationStatus(preConsiderationExamSuite); repoForApprove.CreateConsideration(_consideration); var postConsiderationExamSuite = repoQ.GetQuestionSuite(consideration.ExamSuiteId); var postStatus = repoForApprove.GetConsiderationStatus(postConsiderationExamSuite); var examSuite = repoQ.GetQuestionSuite(consideration.ExamSuiteId); var subject = repoQ.GetInActiveSubject(examSuite.SubjectId); int ExamSuiteAcceptCount = subject.ExamSuiteAcceptCount, ExamSuiteRejectCount = subject.ExamSuiteRejectCount; if (preStatus == "Accepted" && postStatus == "Rejected") { ExamSuiteAcceptCount--; ExamSuiteRejectCount++; } else if (preStatus == "Rejected" && postStatus == "Accepted") { ExamSuiteAcceptCount++; ExamSuiteRejectCount--; } else if (preStatus == "Wait" && postStatus == "Accepted") { ExamSuiteAcceptCount++; } else if (preStatus == "Wait" && postStatus == "Rejected") { ExamSuiteRejectCount++; } repoQ.UpdateQuestionCountComment(examSuite.SubjectId, ExamSuiteAcceptCount, ExamSuiteRejectCount); consideration.id = _consideration._id; consideration.CreateDateTime = _consideration.CreateDateTime; consideration.ExamSuiteId = consideration.ExamSuiteId; consideration.QuestionNumber = QuestionNumber; return(consideration); }
// GET: Considerations/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Consideration consideration = db.Considerations.Find(id); if (consideration == null) { return(HttpNotFound()); } return(View(consideration)); }
// Make a decision: take the consideration with the highest value, then choose an action based on that. // We may add a random modifier to this, bigger if the Soul has the Random personality type. private void DecideCourse() { // Determine most pressing consideration // If AttackEnemy, find own unit closest to an enemy and shoot/move to shoot it // Later, we improve this so it figures out if it should attack with that unit (are we sending infantry against a Gattling?) // Weigh the options to determine which unit to use: weight how much damage the unit would cause against Consideration.PreserveOwnUnits, for example. // Find consideration with highest value Consideration primaryConsideration = Consideration.AttackEnemy; foreach (KeyValuePair <Consideration, float> pair in considerations) { if (pair.Value > considerations[primaryConsideration]) { primaryConsideration = pair.Key; } } // Now tumble down an ugly if tree if (primaryConsideration == Consideration.AttackEnemy) { Debug.Log("Primary consideration: AttackEnemy"); // For now, go through our list of units, see if it can shoot an enemy; if so, shoot. // Keep going until we run out of units? Go through a number of units determined by how high our Consideration value is? (picking the ones with the highest Reward value to perfom this action, e.g. choose ones that deal most damage) /* * List<Unit> unitsAbleToAct = new List<Unit>(player.unitsAbleToAct); // Since a unit will stop being able to act if it shoots, we need to make a copy of the list that doesn't change to properly iterate over it. * foreach (Unit unit in unitsAbleToAct) * { * if (unit.hasEnemyInShootRange) * { * unit.TryToShoot(unit.EnemiesInShootRange[Random.Range(0, unit.EnemiesInShootRange.Count)]); * } * // else, move to nearest enemy? * } */ // Tell a control group with a relevant CGTag to attack. } else if (primaryConsideration == Consideration.PreserveOwnUnits) { Debug.Log("Primary consideration: PreserveOwnUnits"); } else if (primaryConsideration == Consideration.OccupyGoodTerrain) { Debug.Log("Primary consideration: OccupyGoodTerrain"); } }
// GET: Considerations/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Consideration consideration = db.Considerations.Find(id); if (consideration == null) { return(HttpNotFound()); } ViewBag.FactorValueId = new SelectList(db.FactorValues, "id", "Name", consideration.FactorValueId); ViewBag.GeneralParcelId = new SelectList(db.GeneralInfoParcels, "Id", "ParcelNo", consideration.GeneralParcelId); return(View(consideration)); }
public async Task ShouldUseConsiderationToChooseBestGoal() { var planner = PlannerFactory.CreatePlanner(); var agent = new Agent(planner); var goal1 = new TestGoal{Weight = 1}; var goal2 = new TestGoal{Weight = 1}; goal1.AddConsideration(Consideration.FromFunc(d => 0.5f)); goal2.AddConsideration(Consideration.FromFunc(d => 0.2f)); agent.AddGoal(goal1); agent.AddGoal(goal2); await Assert.ThrowsAsync<InvalidOperationException>( async() => await agent.RunActionsAsync()); Assert.Equal(goal1, agent.CurrentGoal); }
private void AddConsiderationButton_Click(object sender, EventArgs e) { if (BehaviorsListView.SelectedItems.Count <= 0) { return; } var behavior = BehaviorsListView.SelectedItems[0].Tag as Behavior; var consideration = new Consideration("New consideration"); if ((new CurveWizardForm(EditingProject, consideration)).ShowDialog() == DialogResult.OK) { behavior.Considerations.Add(consideration); EditingProject.MarkDirty(); } RefreshConsiderationControls(consideration); RefreshBehaviorControls(behavior); }
private void DrawTypeSelect(Rect selectRect, ReflectedProperty property) { Type newConsiderationType; if (property.Value != null) { considerationType = property.Value.GetType(); newConsiderationType = EditorGUIX.ConstructableTypePopup <Consideration>(selectRect, considerationType, FormatTypeName, style); } else { considerationType = null; newConsiderationType = EditorGUIX.ConstructableTypePopup <Consideration>(selectRect, considerationType, FormatTypeName, style); } if (newConsiderationType != considerationType) { considerationType = newConsiderationType; Consideration instance = EditorReflector.MakeInstance <Consideration>(considerationType); property.SetValueAndCopyCompatibleProperties(instance); } }
public double GetInputValue(Consideration consideration) { foreach (EditWidgetConsiderationInput input in InputFlowPanel.Controls) { if (input.Tag == consideration.Input) { if (consideration.Input.KBRec.Params == KnowledgeBase.Record.Parameterization.Enumeration) { var p = consideration.Input.Parameters[0] as InputParameterEnumeration; var v = consideration.ParameterValues[0] as InputParameterValueEnumeration; var comparison = string.Compare(v.Key, input.GetStringValue(), StringComparison.CurrentCultureIgnoreCase); if (p.ScoreOnMatch) { if (comparison == 0) { return(1.0); } return(0.0); } else { if (comparison != 0) { return(1.0); } return(0.0); } } return(input.GetRawValue()); } } return(0.0); }
public RandomScoreAboveThresholdReasoner(string name, Random rng, Consideration <TContext> defaultConsideration, float threshold = 0f) : base(name, defaultConsideration) { _rng = rng; Threshold = threshold; }
public FirstScoreReasoner(string name, Consideration <TContext> defaultConsideration) : base(name, defaultConsideration) { }
public void CreateConsideration(Consideration Consideration) { throw new NotImplementedException(); }
public void addConsideration(Consideration <T> consideration) { considerations.Add(consideration); }
public void RemoveConsideration(Consideration consideration) { considerations.Remove(consideration); }
protected Reasoner(string name, Consideration <TContext> defaultConsideration) { Name = name; DefaultConsideration = defaultConsideration; }
public Reasoner <TContext> RemoveConsideration(Consideration <TContext> consideration) { _considerations.Remove(consideration); return(this); }
public TestAgent(IPlanner planner) : base(planner) { var goal = AddGoal<TestGoal>(1f, Consideration.FromFunc(() => ConsValue)); var action = AddBindableAction(new NoRunAction()); action.BindTo(goal); }
public Reasoner <TContext> AddConsideration(Consideration <TContext> consideration) { _considerations.Add(consideration); return(this); }
public WeightBasedRandomReasoner(string name, Random rng, Consideration <TContext> defaultConsideration, float threshold = 0f) : base(name, defaultConsideration) { _rng = rng; Threshold = threshold; }
public override void Render() { if (rootProperty == null) { return; } SerializedPropertyX contextTypeProp = rootProperty["contextType"]; Type currentType = contextTypeProp.GetValue <Type>(); if (currentType == null) { currentType = typeof(Context); } int idx = 0; for (int i = 1; i < contextTypes.Length; i++) { if (currentType == contextTypes[i]) { idx = i; break; } } int newIdx = EditorGUILayout.Popup("Context Type", idx, contextTypeNames, GUILayout.Width(EditorGUIUtility.labelWidth + 300)); if (idx != newIdx || currentType == null) { Type newType = contextTypes[newIdx]; SerializedPropertyX considerationsProp = rootProperty["considerations"]; SerializedPropertyX requirementsProp = rootProperty["requirements"]; List <SerializedPropertyX> nukeList = new List <SerializedPropertyX>(); for (int i = 0; i < considerationsProp.ChildCount; i++) { Consideration consideration = considerationsProp.GetChildAt(i).Value as Consideration; if (!newType.IsAssignableFrom(consideration.GetContextType())) { nukeList.Add(considerationsProp.GetChildAt(i)); } } for (int i = 0; i < requirementsProp.ChildCount; i++) { Requirement requirement = requirementsProp.GetChildAt(i).Value as Requirement; if (!newType.IsAssignableFrom(requirement.GetContextType())) { nukeList.Add(requirementsProp.GetChildAt(i)); } } if (nukeList.Count > 0) { if (ShouldNuke(nukeList, newType)) { for (int i = 0; i < nukeList.Count; i++) { SerializedPropertyX toNuke = nukeList[i]; int reqChildIndex = requirementsProp.GetChildIndex(toNuke); int conChildIndex = considerationsProp.GetChildIndex(toNuke); requirementsProp.DeleteArrayElementAt(reqChildIndex); considerationsProp.DeleteArrayElementAt(conChildIndex); } contextTypeProp.Value = newType; } } else { contextTypeProp.Value = newType; } } }
static public void Load() { risiaBoss = library.Get <BlueprintUnit>("95fb27a5b8ae40099bd727ea93de5b9b"); BlueprintBrain brain = Helpers.Create <BlueprintBrain>(); BlueprintBuff holyAuraBuff = library.Get <BlueprintBuff>("a33bf327207a5904d9e38d6a80eb09e2"); BlueprintBuff unholyAuraBuff = library.Get <BlueprintBuff>("9eda82a1f78558747a03c17e0e9a1a68"); Consideration hasSwift = getConsideration("c2b7d2f9a5cb8d04d9e1aa4bf3d3c598"); Consideration hasStandard = getConsideration("a82d061edd18ce748a1a7f97e7e6d9d2"); Consideration targetSelf = getConsideration("83e2dd97b82d769498394c3edf0d260e"); Consideration attackTargetPriority = getConsideration("7a2b25dcc09cd244db261ce0a70cca84"); Consideration noShieldBuff = getConsideration("a3ffff7b93017744ea88433311569cec"); Consideration noMirrorBuff = getConsideration("db074912aa8072c469b527f6c111e82c"); Consideration noInvisibilityGreaterBuff = getConsideration("2fc05579e43f56146a1cdaaa82e5119c"); Consideration noFieryBodyBuff = considerNoBuff("RisiaNoFieryBodyBuffConsideration", library.Get <BlueprintBuff>("b574e1583768798468335d8cdb77e94c")); Consideration aroundHasHolyAuraBuff = considerBuffsAround( "RisiaEnemyHasHolyAuraBuffConsideration", TargetType.Enemy, new BlueprintBuff[] { holyAuraBuff } ); Consideration aroundHasUnholyAuraBuff = considerBuffsAround( "RisiaEnemyHasUnholyAuraBuffConsideration", TargetType.Enemy, new BlueprintBuff[] { unholyAuraBuff } ); Consideration selfHasARBoostDCBuff = considerHasBuff( "RisiaHasARBoostDCBuff", ArcaneReservoir.AR_AddDCBuff ); Consideration selfHasNoARBoostDCBuff = considerNoBuff( "RisiaHasNoARBoostDCBuff", ArcaneReservoir.AR_AddDCBuff ); BlueprintAbility shield_swift = getSpell("3c1b92a0a3ce0754a889fb0d7b2c23a4"); BlueprintAbility mirror_swift = getSpell(OtherUtils.GetMd5("Risia.MirrorImageSwift")); BlueprintAbility invisiblity_greater_swift = getSpell(OtherUtils.GetMd5("Risia.GreaterInvisibility.Swift")); BlueprintAbility fiery_body = getSpell("08ccad78cac525040919d51963f9ac39"); BlueprintAbility overwhelmingPresence = getSpell("41cf93453b027b94886901dbfc680cb9"); BlueprintAbility weird = getSpell("870af83be6572594d84d276d7fc583e0"); BlueprintAbility summon7Base = getSpell("ab167fd8203c1314bac6568932f1752f"); BlueprintAbility summon7_1d3 = getSpell("43f763d347eb2744caed9c656ba89531"); BlueprintAbility summon8Base = getSpell("d3ac756a229830243a72e84f3ab050d0"); BlueprintAbility summon8Single = getSpell("eb6df7ddfc0669d4fb3fc9af4bd34bca"); BlueprintAbility DMHolyAura = getSpell(OtherUtils.GetMd5("Risia.DispelMagicArea.HolyAura")); BlueprintAbility DMUnholyAura = getSpell(OtherUtils.GetMd5("Risia.DispelMagicArea.UnholyAura")); BlueprintAbility seamantle_preBuff = getSpell(consts.GUIDs["RisiaSeamantleFree_N"]); BlueprintAbility angelicAspectGreater_preBuff = getSpell(consts.GUIDs["RisiaAngelicAspectFree_N"]); List <BlueprintAiAction> actions = new List <BlueprintAiAction>(); //Free Action Prebuffs //create seamantle var castPrebuffSeamantle = CreateCastSpell( "RisiaCastPrebuffSeamantle", OtherUtils.GetMd5("Risia.Brain.CastPrebuffSeamantle_1001"), seamantle_preBuff, 1001, 0, 0, 1, getConstant(0), 0, null ); var castPrebuffAngelic = CreateCastSpell( "RisiaCastPrebuffAngelic", OtherUtils.GetMd5("Risia.Brain.CastPrebuffAngelic_1000"), angelicAspectGreater_preBuff, 1000, 0, 0, 1, getConstant(0), 0, null ); actions.AddRange(new BlueprintAiCastSpell[] { castPrebuffSeamantle, castPrebuffAngelic }); //Buffs //create cast swift shield var castSwiftShield = CreateCastSpell( "RisiaCastShieldSwift", OtherUtils.GetMd5("Risia.Brain.CastShieldSwift_51.5"), shield_swift, 51.5, 1, 2, 3, getConstant(4), 0, null, hasSwift, targetSelf, noShieldBuff); //create cast swift mirror var castMirror = CreateCastSpell( "RisiaCastMirrorSwift", OtherUtils.GetMd5("Risia.Brain.CastMirrorSwift_53.5"), mirror_swift, 53.5, 1, 2, 5, getConstant(2), 0, null, hasSwift, targetSelf, noMirrorBuff); //create cast swift invisibility greater var castInvisibilityGreater = CreateCastSpell( "RisiaCastIGSwift", OtherUtils.GetMd5("Risia.Brain.CastInvisibilityGreaterSwift_52.5"), invisiblity_greater_swift, 52.5, 1, 2, 2, getConstant(4), 0, null, hasSwift, targetSelf, noInvisibilityGreaterBuff); //create cast fiery body var castFieryBody = CreateCastSpell( "RisiaCastFieryBody", OtherUtils.GetMd5("Risia.Brain.CastFieryBody_afterShield_51.0"), fiery_body, 51.0, 1, 2, 1, getConstant(0), 0, null, hasStandard, targetSelf, noFieryBodyBuff); actions.AddRange(new BlueprintAiCastSpell[] { castSwiftShield, castMirror, castInvisibilityGreater, castFieryBody }); // Control spells var castDMHolyAura = CreateCastSpell( "RisiaCastDMHolyAura", OtherUtils.GetMd5("Risia.Brain.CastDMHolyAuraOnly_40.0"), DMHolyAura, 40.0, 1, 1, 2, getConstant(3), 0, null, hasStandard, aroundHasHolyAuraBuff ); var castDMUnholyAura = CreateCastSpell( "RisiaCastDMUnholyAura", OtherUtils.GetMd5("Risia.Brain.CastDMUnholyAuraOnly_40.0"), DMUnholyAura, 40.0, 1, 1, 2, getConstant(3), 0, null, hasStandard, aroundHasUnholyAuraBuff ); var castArcaneReserviorBoostDC = CreateCastSpell( "RisiaCastArcaneReservoirBoostDC", OtherUtils.GetMd5("Risia.Brain.ArcaneReservoirBoostDC_19.9"), ArcaneReservoir.AR_AddDCAbl, 19.9, 2, 0, 10, getConstant(1), 0, null, hasStandard, selfHasNoARBoostDCBuff); var castOverwhelmingPresence = CreateCastSpell( "RisiaCastOverwhelming", OtherUtils.GetMd5("Risia.Brain.CastOverwhelming_19.0"), overwhelmingPresence, 19.0, 3, 1, 2, getConstant(4), 0, null, considerSpellSlot(9), hasStandard, selfHasARBoostDCBuff, attackTargetPriority ); var castWeird = CreateCastSpell( "RisiaCastWeird", OtherUtils.GetMd5("Risia.Brain.CastWeird_20.0"), weird, 19.0, 3, 1, 2, getDice(2, DiceType.D3), 0, null, considerSpellSlot(9), hasStandard, selfHasARBoostDCBuff, attackTargetPriority ); //var castPowerWordStun = CreateCastSpell( //) actions.AddRange(new BlueprintAiCastSpell[] { castDMHolyAura, castDMUnholyAura, castOverwhelmingPresence }); // Summon spells var castSummon7 = CreateCastSpell( "RisiaCastSummonVII1d3", OtherUtils.GetMd5("Risia.Brain.CastSummonVII1d3_Consecute_25.0"), summon7Base, 25.0, 0, 0, 3, getDice(2, DiceType.D3), 2, summon7_1d3 ); var castSummon8 = CreateCastSpell( "RisiaCastSummonVIII", OtherUtils.GetMd5("Risia.Brain.CastSummonVIIISingle_Consecute_25.0"), summon8Base, 25.0, 0, 0, 3, getDice(1, DiceType.D6), 3, summon8Single ); actions.AddRange(new BlueprintAiCastSpell[] { castSummon7, castSummon8 }); // Attack actions.Add(library.Get <BlueprintAiAction>("866ffa6c34000cd4a86fb1671f86c7d8"));//simple attack brain.Actions = actions.ToArray(); brain.name = "Risia.Brain"; library.AddAsset(brain, OtherUtils.GetMd5("Risia.Boss.Brain")); risiaBoss.Brain = brain; }