private void getPawnAttack(ref List <Move> legalMoves, Belief belief) { int offset = isWhite ? 1 : 1; Point right = new Point(position.getX() + 1, position.getY() + offset); Point left = new Point(position.getX() - 1, position.getY() + offset); if (right.validPosition()) { if (belief.isOccupied(right)) { if (!belief.isOccupiedWithMyPiece(right, isWhite)) { legalMoves.Add(new Move(position, right)); } } } if (left.validPosition()) { if (belief.isOccupied(left)) { if (!belief.isOccupiedWithMyPiece(left, isWhite)) { legalMoves.Add(new Move(position, left)); } } } }
public belief() { var received = new[] { V.empty, V.empty, V.B, V.C, V.A, V.empty, V.empty }; var root = new Belief(); root.variable = "v-ith"; var v_ith = root; foreach (var i in received) { var v_jth_given_v_ith = belief.Belief_NextChar_PreviousChar; var v_kth_given_v_jth = belief.Belief_CorruptedChar_SentChar; v_ith.Causes(v_jth_given_v_ith); v_jth_given_v_ith.Causes(v_kth_given_v_jth); v_ith = v_kth_given_v_jth; } this.Root = root; InitializeComponent(); }
public override void collect() { CharacterAbstract me = AI_.Character_; for (int i = 0; i < WorldState.AmmoList_.Count; i++) { AmmoBox box = WorldState.AmmoList_[i]; if (ReservationTable.isReserved(box)) { AI_.Memory_.removeBelief(BeliefType.AmmoLoc, box); continue; } if (Raycaster.inFieldOfView(me.getDirection(), me.getPosition(), box.getPosition(), fieldOfView) && Raycaster.canSeePoint(me.getPosition(), box.getPosition(), me.getHeight(), box.getHeight())) { if (box.hasBeenPickedUp()) { AI_.Memory_.removeBelief(BeliefType.AmmoLoc, box); continue; } Belief posBelief = new Belief(BeliefType.AmmoLoc, box, 100); posBelief.position_ = box.getPosition(); posBelief.relevance_ = (float)(1 / (box.getPosition() - AI_.Character_.getPosition()).LengthSquared()); posBelief.data_.tile1 = GlobalHelper.getInstance().getCurrentLevelTileGrid().getTileIndex(box.getPosition()); AI_.Memory_.setBelief(posBelief); } } }
// Used for saving site observation beliefs to ownship and forwarding to neighbors public void RegisterSiteObservation(Belief b) { if (b is Belief_Base || b is Belief_NGOSite || b is Belief_Village) { addMyBeliefData(b); } }
private async Task <ObservableCollection <Belief> > GetAllBeliefs(Topic topic) { ObservableCollection <Belief> returnList = new ObservableCollection <Belief>(); try { string beliefList = await Belief.ListBeliefsAsync(topic.ID).ConfigureAwait(false); JArray data = JArray.Parse(beliefList); foreach (JToken entry in data) { returnList.Add(new Belief(m_client) { beliefText = entry["beliefText"].ToString(), userID = int.Parse(entry["user_id"].ToString()), topicID = int.Parse(entry["topic_id"].ToString()), ID = int.Parse(entry["id"].ToString()) }); } } catch (Exception e) { m_errorMessages.Add(e.Message); } return(returnList); }
static void Main(string[] args) { Belief b = new Belief("p, q, p > q, a, !b, !c, y, z, z > x, y > a"); Console.WriteLine("\n"); Console.WriteLine("\n"); Console.WriteLine("Welcome to our belief revision assignment! Please make sure that every belief you enter have spaces between each proposition and operator, otherwise the program may not work as intended."); Console.WriteLine("Please note that we have decided to use ! as negation, <> as biconditional, > as implication, V as disjunction and & as conjuction operators. This is done, because of easier symbols on a pc."); Console.WriteLine("\n"); Console.WriteLine("\n"); while (true) { Console.WriteLine("Your current belief base is: " + b.PrintBeliefs()); Console.WriteLine("\n"); Console.WriteLine("Please enter your new belief (exit to exit):"); string belief = Console.ReadLine(); if (belief.Equals("exit")) { break; } else { b.Revise(belief); } } }
//Add data from the sensors of this actor (position updates, sensor data). This goes to the belief dictionary and the remote beliefs to be sent. private void addMyBeliefData(Belief b) { if (beliefRepo.Commit(b)) { dataManager.synchronizeBelief(b, unique_id); } }
public void Initialize() { _cognitiveArchitecture = new CognitiveArchitecture { KnowledgeAndBeliefs = { HasBelief = true, HasKnowledge = true }, MessageContent = { CanReceiveBeliefs = true, CanReceiveKnowledge = true }, InternalCharacteristics = { CanLearn = true, CanForget = true, CanInfluenceOrBeInfluence = true } }; _knowledge = new Knowledge(Network, MainOrganization.Models, "1", 1); var modelEntity = new BeliefModelEntity { On = true }; _beliefsModel = new BeliefsModel(_agentId, modelEntity, _cognitiveArchitecture, Network, MainOrganization.Models.Generator); _belief = new Belief(Network, 1, RandomGenerator.RandomUniform, BeliefWeightLevel.RandomWeight); _beliefBitsNonNeutral = _belief.InitializeBits(MainOrganization.Models.Generator, BeliefLevel.NeitherAgreeNorDisagree); _beliefBitsNeutral = _belief.InitializeBits(MainOrganization.Models.Generator, BeliefLevel.NoBelief); _actorBelief = new ActorBelief(Network.ActorBelief, _agentId, _belief.EntityId, BeliefLevel.NeitherAgreeNorDisagree); _taskBits.SetMandatory(new byte[] { 0 }); _taskBits.SetRequired(new byte[] { 0 }); }
private void getRoque(Belief belief, ref List <Move> legalMoves) { if (isWhite) { //petit roque if (isFirstMove && !belief.isOccupied(5, 0) && !belief.isOccupied(6, 0) && belief.getCase(7, 0).getPiece() is Rook && belief.getCase(7, 0).getPiece().isFirstMove) { legalMoves.Add(new Move(position, new Point(6, 0))); } //grand roque if (isFirstMove && !belief.isOccupied(1, 0) && !belief.isOccupied(2, 0) && !belief.isOccupied(3, 0) && belief.getCase(1, 0).getPiece() is Rook && belief.getCase(1, 0).getPiece().isFirstMove) { legalMoves.Add(new Move(position, new Point(2, 0))); } } else { //petit roque if (isFirstMove && !belief.isOccupied(5, 7) && !belief.isOccupied(6, 7) && belief.getCase(7, 7).getPiece() is Rook && belief.getCase(7, 7).getPiece().isFirstMove) { legalMoves.Add(new Move(position, new Point(6, 7))); } //grand roque if (isFirstMove && !belief.isOccupied(1, 7) && !belief.isOccupied(2, 7) && !belief.isOccupied(3, 7) && belief.getCase(1, 7).getPiece() is Rook && belief.getCase(1, 7).getPiece().isFirstMove) { legalMoves.Add(new Move(position, new Point(2, 7))); } } }
static Result ToResult( Belief b, string token, string type, Func <string, string, string> reason) => b.ToResult( Analyzer.DiagnosticId, $"The name '{token}' is too easy: {reason(token, type)}");
public override List <Move> getPossibleMoves(Belief belief) { Rook r = new Rook(position.getX(), position.getY(), isWhite); Bishop b = new Bishop(position.getX(), position.getY(), isWhite); return(r.getPossibleMoves(belief).Union(b.getPossibleMoves(belief)).ToList()); }
public override void updateDesire(List <Belief> beliefs, Emotion emotion) { List <Belief> resourceBeliefs = beliefs.FindAll(b => b.Subject.tag == Elements.RESOURCE); Belief villageBelief = beliefs.Find(b => b.Subject.tag == Elements.VILLAGE); Belief selfBelief = beliefs.Find(b => b.Subject.Equals(self) && b.Name.Equals("IExist")); if (self.GetComponent <CharacterVars>().currentResource >= self.GetComponent <CharacterVars>().maxResource) { this.intensity = 0f; return; } // Have the intensity be inverse to the proportion of resources believed to be in the village if (villageBelief != null) { // TODO: Have in mind the certainty about this this.intensity = 1f / (float)Math.Sqrt(villageBelief.attributes [Elements.RESOURCE]); return; } float intensity = 0; foreach (Belief belief in resourceBeliefs) { intensity += belief.attributes [Elements.RESOURCE]; } this.intensity = Math.Min(1f, intensity / (self.GetComponent <CharacterVars>().maxResource - self.GetComponent <CharacterVars>().currentResource)); // Generic boost of intensity when emotive, penalization when depressed this.intensity += ((1f - this.intensity) * emotion.intensity); }
private async Task <ObservableCollection <Verse> > GetAllVerses(Belief belief) { ObservableCollection <Verse> returnList = new ObservableCollection <Verse>(); try { string verseList = await Verse.ListVersesAsync(belief.topicID, belief.ID).ConfigureAwait(false); JArray data = JArray.Parse(verseList); foreach (JToken entry in data) { returnList.Add(new Verse(m_client) { userID = int.Parse(entry["user_id"].ToString()), topicID = belief.topicID, beliefID = int.Parse(entry["belief_id"].ToString()), ID = int.Parse(entry["id"].ToString()), verse = entry["verse"].ToString(), book = int.Parse(entry["book"].ToString()), chapter = int.Parse(entry["chapter"].ToString()), verseStart = int.Parse(entry["verseStart"].ToString()), verseEnd = int.Parse(entry["verseEnd"].ToString()) }); } } catch (Exception e) { m_errorMessages.Add(e.Message); } return(returnList); }
private async Task InitializeClientAndUser() { try { // Initialize HTTP Client m_client = new HttpClient(); m_client.BaseAddress = new Uri("http://*****:*****@test.com"; var tokenResponse = await User.LoginUserAsync(m_user).ConfigureAwait(false); m_user.token = tokenResponse.ToString(); } //Set the token in the HTTP header to allow the user to access other parts of the API m_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", m_user.token); Topic topic = new Topic(m_client); Belief belief = new Belief(m_client); Verse verse = new Verse(m_client); } catch (Exception e) { m_errorMessages.Add(e.Message); } }
public ActionResult DeleteConfirmed(int id) { Belief belief = db.Belief.Find(id); db.Belief.Remove(belief); db.SaveChanges(); return(RedirectToAction("Admin")); }
public void Initialize() { MainOrganization.Models.Generator = RandomGenerator.RandomUniform; MainOrganization.Models.BeliefWeightLevel = BeliefWeightLevel.RandomWeight; MainOrganization.Models.Beliefs.On = true; _knowledge = new Knowledge(Network, MainOrganization.Models, "1", 10); _belief = _knowledge.AssociatedBelief; }
public void Chapter4_Example3through6() { var X = new Belief { variable = "the last user of the weapon" }; var Y = new Belief { variable = "the last holder of the weapon", ConditionalProbability = new decimal[][] { new decimal[] { 0.8M, 0.1M, 0.1M }, new decimal[] { 0.1M, 0.8M, 0.1M }, new decimal[] { 0.1M, 0.1M, 0.8M }, } }; X.Causes(Y); (0.66M).Assert_AboutEqual(Y.CausalSupport[0][0]); (0.17M).Assert_AboutEqual(Y.CausalSupport[0][1]); (0.17M).Assert_AboutEqual(Y.CausalSupport[0][2]); Y.UpdateDiagnosticSupport(0, new decimal[] { 0.8M, 0.6M, 0.5M }); (0.738M).Assert_AboutEqual(Y.Value[0][0]); (0.143M).Assert_AboutEqual(Y.Value[0][1]); (0.119M).Assert_AboutEqual(Y.Value[0][2]); (0.84M).Assert_AboutEqual(X.Value[0][0]); (0.085M).Assert_AboutEqual(X.Value[0][1]); (0.076M).Assert_AboutEqual(X.Value[0][2]); var alibi = new decimal[] { 0.28M, 0.36M, 0.36M }; X.CausalSupport[0] = alibi; X.UpdateBelief(0); (0.337M).Assert_AboutEqual(X.Value[0][0]); (0.352M).Assert_AboutEqual(X.Value[0][1]); //Rounding error between test and priis pg. 160 orginal is 0.311M (0.312M).Assert_AboutEqual(X.Value[0][2]); Y.UpdateCausalSupport(0, alibi); //Seems like another rounding error as 2 is equal while 0 and 1 are off by .005 or so //(0.384M).IsEqualTo(Y.Belief[0][0]); //(0.336M).IsEqualTo(Y.Belief[0][1]); //(0.28M).IsEqualTo(Y.Belief[0][2]); Y.UpdateDiagnosticSupport(0, new decimal[] { 0.3M, 0.5M, 0.9M }); //more round error. Between 0 and 2. Things still add to 1 so that is good. (0.215M).Assert_AboutEqual(Y.Value[0][0]); (0.314M).Assert_AboutEqual(Y.Value[0][1]); (0.471M).Assert_AboutEqual(Y.Value[0][2]); }
public void AddBeliefFromKnowledgeIdTest() { Assert.IsNull(_beliefsModel.GetBeliefFromKnowledgeId(_knowledge.EntityId)); var belief = new Belief(Network, _knowledge, _knowledge.Length, RandomGenerator.RandomUniform, BeliefWeightLevel.RandomWeight); _beliefsModel.AddBeliefFromKnowledgeId(_knowledge.EntityId); Assert.IsNotNull(_beliefsModel.GetBelief(belief.EntityId)); }
public ActionResult Edit([Bind(Include = "BeliefID,BeliefTitle,BeliefDetails")] Belief belief) { if (ModelState.IsValid) { db.Entry(belief).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Admin")); } return(View(belief)); }
// Use this for initialization public BDI(Agent agent) { myAgent = agent; belief = new Belief(); desire = new Desire(agent.GetType()); intention = null; perception = new Perception(myAgent); feelings = new Feelings(); reasoning = new Reasoning(); }
static Result Expected(Belief b) { var token = b.Message; return(b.ToResult( Analyzer.DiagnosticId, $"Use 'is' pattern matching instead of " + $"'{token}' operator.", DiagnosticSeverity.Info)); }
static Result Expected(Belief b) { var array = b.Message.Split(' '); var name = array[0]; var arrayName = array[1]; return(b.ToResult( Analyzer.DiagnosticId, $"'{name}.ReadByte()' must be rewritten using " + $"with '{name}.Read({arrayName}, int, int)'")); }
static Result Expected(Belief b) { var all = b.Message.Split("|"); var oldOne = all[0]; var newOne = all[1]; return(b.ToResult( Analyzer.DiagnosticId, $"Replace '{oldOne}' with '{newOne}' to use an " + "implicitly-typed array creation.")); }
public void Initialize() { MainOrganization.Models.SetOn(1); _belief = new Belief(MainOrganization.ArtifactNetwork, 1, RandomGenerator.RandomUniform, BeliefWeightLevel.RandomWeight); Environment.SetOrganization(MainOrganization); _beliefsModel = new BeliefsModel(_agentId, MainOrganization.Models.Beliefs, _cognitiveArchitecture, MainOrganization.ArtifactNetwork, MainOrganization.Models.Generator); _influenceModel = new InfluenceModel(MainOrganization.Models.Influence, _cognitiveArchitecture, WhitePages, _beliefsModel, MainOrganization.Models.Generator); }
public ActionResult Create([Bind(Include = "BeliefID,BeliefTitle,BeliefDetails")] Belief belief) { if (ModelState.IsValid) { db.Belief.Add(belief); db.SaveChanges(); return(RedirectToAction("Admin")); } return(View(belief)); }
public void Initialize() { var agentId = new AgentId(1, 1); _belief0 = new Belief(Network, 0, Model, BeliefWeightLevel.RandomWeight); _belief1 = new Belief(Network, 1, Model, BeliefWeightLevel.RandomWeight); _belief2 = new Belief(Network, 2, Model, BeliefWeightLevel.RandomWeight); _actorBelief0 = new ActorBelief(agentId, _belief0.EntityId, BeliefLevel.NeitherAgreeNorDisagree); _actorBelief1 = new ActorBelief(agentId, _belief1.EntityId, BeliefLevel.NeitherAgreeNorDisagree); _actorBelief2 = new ActorBelief(agentId, _belief2.EntityId, BeliefLevel.NeitherAgreeNorDisagree); }
// Use this for initialization public BDI(Agent agent) { myAgent = agent; MesoGroup mesoGroup = new MesoGroup(agent.Settings.MyGroup); belief = new Belief(mesoGroup); desire = new Desire(agent.GetType()); intention = null; perception = new Perception(myAgent); feelings = new Feelings(); reasoning = new Reasoning(); }
private static Result Expected(Belief b) { var array = b.Message.Split(','); var parameterName = array[0]; var functionKind = KindSet[array[1]]; var functionName = array[2]; return(b.ToResult( Analyzer.DiagnosticId, $"The parameter '{parameterName}' of the {functionKind} " + $"'{functionName}' must be replaced with the type " + $"parameter.")); }
public void InitializeBitsTest3(BeliefLevel level) { var knowledgeBits = _belief.InitializeBits(RandomGenerator.RandomUniform, level); for (byte i = 0; i < _knowledge.Length; i++) { Assert.IsTrue( Belief.GetMinFromBeliefLevel(level) <= knowledgeBits[i] || Math.Abs(knowledgeBits[i]) < Tolerance); Assert.IsTrue(knowledgeBits[i] <= Belief.GetMaxFromBeliefLevel(level)); } }
/// <summary> /// Examine all characters stored in the world state, determine if we can see them, and if /// we can, deduce useful information about them. /// </summary> public override void collect() { CharacterAbstract me = AI_.Character_; for (int i = 0; i < WorldState.CharacterList_.Count; i++) { CharacterAbstract character = WorldState.CharacterList_[i]; BeliefType locationType; BeliefType healthType; if (me.Allegiance_ == character.Allegiance_) { locationType = BeliefType.AllyLoc; healthType = BeliefType.AllyHealth; } else { locationType = BeliefType.EnemyLoc; healthType = BeliefType.EnemyHealth; } // First see if the character is dead if (character.isDead()) { AI_.Memory_.removeBelief(locationType, character); AI_.Memory_.removeBelief(healthType, character); continue; } // Then see if I can see the character if (me != character && Raycaster.inFieldOfView(me.getDirection(), me.getPosition(), character.getPosition(), fieldOfView) && Raycaster.canSeePoint(me.getPosition(), character.getPosition(), me.getHeight(), character.getHeight())) { Belief posBelief = new Belief(locationType, character, 100); posBelief.position_ = character.getPosition(); Belief healthBelief = new Belief(healthType, character, 100); healthBelief.position_ = character.getPosition(); healthBelief.data_.int1 = character.getHealth().getValue(); AI_.Memory_.setBelief(posBelief); AI_.Memory_.setBelief(healthBelief); } } // TODO // Reimplement this correctly // Update the position and confidence of the AllyLoc and EnemyLoc beliefs foreach (Belief bel in AI_.Memory_.getBeliefs(BeliefType.EnemyLoc)) { bel.confidence_ -= .4f; } }
// GET: Beliefs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Belief belief = db.Belief.Find(id); if (belief == null) { return(HttpNotFound()); } return(View(belief)); }
private async Task <List <Belief> > GetAllBeliefs() { List <Belief> returnList = new List <Belief>(); try { string beliefList = await Belief.ListBeliefsAsync(1).ConfigureAwait(false); } catch (Exception e) { m_errorMessages.Add(e.Message); } return(returnList); }
public override void collect() { if (AI_.Memory_.getFirstBelief(BeliefType.CoverLoc) == null) { List<CoverObject> coverObjects = WorldState.CoverList_; for (int i = 0; i < coverObjects.Count; i++) { Vector2 location = coverObjects[i].needsToMove(coverObjects[i].getPosition(), AI_.Character_.getRadius()); TileIndex index = GlobalHelper.getInstance().getCurrentLevelTileGrid().getTileIndex(location); Belief cover = new Belief(BeliefType.CoverLoc, coverObjects[i], 100f); cover.position_ = location; cover.data_.tile1 = index; AI_.Memory_.setBelief(cover); } } }
private void filter(int id, Stimulus stim) { if (CommonFunctions.distance(AI_.Character_.getPosition(), stim.position_) < (double) stim.radius_) { if (stim.type_ == StimulusType.Position) { Belief b = new Belief(BeliefType.SuspiciousNoise, null, 100); b.position_ = stim.position_; AI_.Memory_.setBelief(b); } else if (stim.type_ == StimulusType.Message && stim.sourceAllegiance_ == AI_.Character_.Allegiance_ && stim.handle_ != AI_.Character_ && !idsHeardBefore.Contains(stim.message_.Id_)) { if (AI_.CommunicationSystem_.communicationLevel_ == SystemCommunication.CommunicationLevel.High && stim.message_.MessageType_ == Message.MessageType.Data) { CommLogger.addOutput("Heard " + stim.message_.ToString()); } idsHeardBefore.Add(stim.message_.Id_); bool isRedundant = false; AI_.CommunicationSystem_.IsListening_ = true; if (stim.message_.MessageType_ == Message.MessageType.Data) { isRedundant = AI_.Memory_.getAllBeliefs().Contains(stim.message_.Belief_); // For now, we believe messages that we receive with 100% certainty AI_.Memory_.setBelief(stim.message_.Belief_); } else if (stim.message_.MessageType_ == Message.MessageType.Hi) { // Someone has requested communication AI_.CommunicationSystem_.communicationRequested_ = true; } else if (stim.message_.MessageType_ == Message.MessageType.Bye) { // End of communication. // Now that I think of it, there's really no reason for a Bye. } if (AI_.CommunicationSystem_.communicationLevel_ == SystemCommunication.CommunicationLevel.High && stim.message_.MessageType_ == Message.MessageType.Data) { CommLogger.recvdMsg(isRedundant); } } } }
internal override void allocateTasks(List<AI> teamMembers) { bool isFlushed = false; for (int i = 0; i < teamMembers.Count; i++) { GoalTeamwork goal = teamMembers[i].GoalManager_.getTeamGoal(); if (!isFlushed && teamMembers[i].Memory_.getBelief(BeliefType.BestTarget, target_) != null) { goal.setNode(flushTask); isFlushed = true; } else { goal.setNode(suppressTask); } goal.HasFailed_ = false; goal.Relevance_ = Relevance_; teamMembers[i].Memory_.removeBeliefs(BeliefType.TeamInfo); Belief teamBelief = new Belief(BeliefType.TeamInfo, target_, 100); teamMembers[i].Memory_.setBelief(teamBelief); } }
/// <summary> /// Removes a belief from memory. /// </summary> /// <param name="belief">The exact belief to be removed (not a copy).</param> /// <returns>True if the belief was removed, false if it was not there.</returns> public bool removeBelief(Belief belief) { // Test that we even have beliefs of this type List<Belief> list; if (!beliefs_.TryGetValue(belief.type_, out list)) { return false; } // Try and remove this belief, and update the cache if necessary bool wasRemoved = list.Remove(belief); if (isCached(belief)) { updateCachedBelief(belief.type_); } return list.Remove(belief); }
/// <summary> /// Replaces a belief with matching type_ and handle_, or adds a new /// belief if a match does not exist. /// </summary> /// <param name="belief">Belief to store in memory.</param> public void setBelief(Belief belief) { List<Belief> list; if (!beliefs_.TryGetValue(belief.type_, out list)) { beliefs_[belief.type_] = new List<Belief>(); beliefs_[belief.type_].Add(belief); cachedBeliefs_.Add(belief.type_, belief); return; } Belief temp = list.Find(delegate(Belief b) { return b.handle_ == belief.handle_; }); if (temp != null) { bool relevanceReduced = (temp.relevance_ < belief.relevance_); temp.replace(belief); if (relevanceReduced && isCached(temp)) { updateCachedBelief(belief.type_); } } else { list.Add(belief); updateCachedBelief(belief); } }
/// <summary> /// Safely changes the relevance of a belief in memory. /// </summary> /// <param name="belief">Belief whose relevance will be changed.</param> /// <param name="relevance">New relevance for the belief.</param> public void updateRelevance(Belief belief, float relevance) { bool relevanceReduced = (relevance < belief.relevance_); belief.relevance_ = relevance; // if relevance was reduced and this belief was cached, refresh // the cache for that type if (relevanceReduced && isCached(belief)) { updateCachedBelief(belief.type_); } // otherwise if relevance improved or stayed safe, see if this // belief now belongs in the cache else if (!relevanceReduced) { updateCachedBelief(belief); } }
/// <summary> /// Tests whether a given belief is the currently cached belief. /// </summary> /// <param name="belief">The belief to test against the cache.</param> /// <returns>True if the belief is the cached belief, false otherwise.</returns> protected bool isCached(Belief belief) { return (cachedBeliefs_.ContainsKey(belief.type_) && cachedBeliefs_[belief.type_] == belief); }
/// <summary> /// Compares a belief against the cached belief and makes /// a replacement of the cached belief if the argument belief /// has a higher relevance. /// </summary> /// <param name="belief">Belief to be tested against the cache.</param> protected void updateCachedBelief(Belief belief) { Belief cached; cachedBeliefs_.TryGetValue(belief.type_, out cached); if (cached == null) { cachedBeliefs_.Add(belief.type_, belief); } else { if (belief.relevance_ > cached.relevance_) { cachedBeliefs_[belief.type_] = belief; } } }