示例#1
0
        public bool Equals(BeliefsAboutAgent anotherBeliefsAboutAgent)
        {
            if (anotherBeliefsAboutAgent == null)
            {
                return(false);
            }

            bool infoEquals          = info.Equals(anotherBeliefsAboutAgent.info);
            bool infoReferenceEquals = object.ReferenceEquals(info, anotherBeliefsAboutAgent.info);

            bool roleEquals          = (role == anotherBeliefsAboutAgent.role);
            bool roleReferenceEquals = object.ReferenceEquals(role, anotherBeliefsAboutAgent.role);

            bool statusEquals          = (isAlive == anotherBeliefsAboutAgent.isAlive);
            bool statusReferenceEquals = object.ReferenceEquals(isAlive, anotherBeliefsAboutAgent.isAlive);

            bool inLocationEquals          = inLocation.Equals(anotherBeliefsAboutAgent.inLocation);
            bool inLocationReferenceEquals = object.ReferenceEquals(inLocation, anotherBeliefsAboutAgent.inLocation);

            bool angryAtEquals          = angryAt.Equals(anotherBeliefsAboutAgent.angryAt);
            bool angryAtReferenceEquals = object.ReferenceEquals(angryAt, anotherBeliefsAboutAgent.angryAt);

            bool infoGlobal       = infoEquals || infoReferenceEquals;
            bool roleGlobal       = roleEquals || roleReferenceEquals;
            bool statusGlobal     = statusEquals || statusReferenceEquals;
            bool inLocationGlobal = inLocationEquals || inLocationReferenceEquals;
            bool angryAtGlobal    = angryAtEquals || angryAtReferenceEquals;

            bool equal = infoGlobal && roleGlobal && statusGlobal && inLocationGlobal && angryAtGlobal;

            return(equal);
        }
示例#2
0
        public bool Equals(LocationDynamic anotherLocation)
        {
            if (anotherLocation == null)
            {
                return(false);
            }

            bool locationInfoEquals          = locationInfo.Equals(anotherLocation.locationInfo);
            bool locationInfoReferenceEquals = object.ReferenceEquals(locationInfo, anotherLocation.locationInfo);

            bool agentsAtLocationEquals          = true;
            bool agentsAtLocationReferenceEquals = true;

            if (agentsAtLocations.Count == anotherLocation.agentsAtLocations.Count)
            {
                for (int i = 0; i < agentsAtLocations.Count; i++)
                {
                    if (!agentsAtLocations.Keys.ElementAt(i).Equals(anotherLocation.agentsAtLocations.Keys.ElementAt(i)) ||
                        !agentsAtLocations.Values.ElementAt(i).Equals(anotherLocation.agentsAtLocations.Values.ElementAt(i)))
                    {
                        agentsAtLocationEquals = false;
                    }
                    if (!object.ReferenceEquals(agentsAtLocations.Keys.ElementAt(i), anotherLocation.agentsAtLocations.Keys.ElementAt(i)) ||
                        !object.ReferenceEquals(agentsAtLocations.Values.ElementAt(i), anotherLocation.agentsAtLocations.Values.ElementAt(i)))
                    {
                        agentsAtLocationReferenceEquals = false;
                    }
                }
            }
            else
            {
                agentsAtLocationEquals          = false;
                agentsAtLocationReferenceEquals = false;
            }

            bool containEvidenceEquals          = (containEvidence == anotherLocation.containEvidence);
            bool containEvidenceReferenceEquals = object.ReferenceEquals(containEvidence, anotherLocation.containEvidence);

            bool locationInfoGlobal     = locationInfoEquals || locationInfoReferenceEquals;
            bool agentsAtLocationGlobal = agentsAtLocationEquals || agentsAtLocationReferenceEquals;
            bool containEvidenceGlobal  = containEvidenceEquals || containEvidenceReferenceEquals;

            bool equal = locationInfoGlobal && agentsAtLocationGlobal && containEvidenceGlobal;

            return(equal);
        }
        public bool Equals(WantToEntrap anotherWantToEntrap)
        {
            if (anotherWantToEntrap == null)
            {
                return(false);
            }

            bool entrapingEquals          = (entraping == anotherWantToEntrap.entraping);
            bool entrapingReferenceEquals = object.ReferenceEquals(entraping, anotherWantToEntrap.entraping);

            bool whomEquals;
            bool whomReferenceEquals;

            if (whom == null && anotherWantToEntrap.whom == null)
            {
                whomEquals          = true;
                whomReferenceEquals = true;
            }
            else
            {
                whomEquals          = whom.Equals(anotherWantToEntrap.whom);
                whomReferenceEquals = object.ReferenceEquals(whom, anotherWantToEntrap.whom);
            }

            bool whereEquals;
            bool whereReferenceEquals;

            if (where == null && anotherWantToEntrap.where == null)
            {
                whereEquals          = true;
                whereReferenceEquals = true;
            }
            else
            {
                whereEquals          = where.Equals(anotherWantToEntrap.where);
                whereReferenceEquals = object.ReferenceEquals(where, anotherWantToEntrap.where);
            }

            bool entrapingGlobal = entrapingEquals || entrapingReferenceEquals;
            bool whomGlobal      = whomEquals || whomReferenceEquals;
            bool whereGlobal     = whereEquals || whereReferenceEquals;

            bool equal = entrapingGlobal && whomGlobal && whereGlobal;

            return(equal);
        }
示例#4
0
        public bool Equals(WorldContext anotherWorldContext)
        {
            if (anotherWorldContext == null)
            {
                return(false);
            }

            bool myLocationEquals          = myLocation.Equals(anotherWorldContext.myLocation);
            bool myLocationReferenceEquals = object.ReferenceEquals(myLocation, anotherWorldContext.myLocation);

            bool anotherAgentsInMyLocationEquals          = true;
            bool anotherAgentsInMyLocationReferenceEquals = true;

            for (int i = 0; i < anotherAgentsInMyLocation.Count; i++)
            {
                if (!anotherAgentsInMyLocation.ElementAt(i).Equals(anotherWorldContext.anotherAgentsInMyLocation.ElementAt(i)))
                {
                    anotherAgentsInMyLocationEquals = false;
                }
                if (!object.ReferenceEquals(anotherAgentsInMyLocation.ElementAt(i), anotherWorldContext.anotherAgentsInMyLocation.ElementAt(i)))
                {
                    anotherAgentsInMyLocationReferenceEquals = false;
                }
            }

            bool agentsInWorldEquals          = true;
            bool agentsInWorldReferenceEquals = true;

            for (int i = 0; i < agentsInWorld.Count; i++)
            {
                if (!agentsInWorld.ElementAt(i).Equals(anotherWorldContext.agentsInWorld.ElementAt(i)))
                {
                    agentsInWorldEquals = false;
                }
                if (!object.ReferenceEquals(agentsInWorld.ElementAt(i), anotherWorldContext.agentsInWorld.ElementAt(i)))
                {
                    agentsInWorldReferenceEquals = false;
                }
            }

            bool locationsInWorldEquals          = true;
            bool locationsInWorldReferenceEquals = true;

            for (int i = 0; i < locationsInWorld.Count; i++)
            {
                if (!locationsInWorld.ElementAt(i).Equals(anotherWorldContext.locationsInWorld.ElementAt(i)))
                {
                    locationsInWorldEquals = false;
                }
                if (!object.ReferenceEquals(locationsInWorld.ElementAt(i), anotherWorldContext.locationsInWorld.ElementAt(i)))
                {
                    locationsInWorldReferenceEquals = false;
                }
            }

            bool myLocationGlobal = myLocationEquals || myLocationReferenceEquals;
            bool anotherAgentsInMyLocationGlobal = anotherAgentsInMyLocationEquals || anotherAgentsInMyLocationReferenceEquals;
            bool agentsInWorldGlobal             = agentsInWorldEquals || agentsInWorldReferenceEquals;
            bool locationsInWorldGlobal          = locationsInWorldEquals || locationsInWorldReferenceEquals;

            bool equal = myLocationGlobal && anotherAgentsInMyLocationGlobal && agentsInWorldGlobal && locationsInWorldGlobal;

            return(equal);
        }
示例#5
0
        public bool Equals(AgentStateDynamic anotherState)
        {
            if (anotherState == null)
            {
                return(false);
            }

            bool agentInfoEquals          = agentInfo.Equals(anotherState.agentInfo);
            bool agentInfoReferenceEquals = object.ReferenceEquals(agentInfo, anotherState.agentInfo);

            bool statusEquals          = (alive == anotherState.alive);
            bool statusReferenceEquals = object.ReferenceEquals(alive, anotherState.alive);

            bool goalsEquals          = myGoals.Equals(anotherState.myGoals);
            bool goalsReferenceEquals = object.ReferenceEquals(myGoals, anotherState.myGoals);

            bool initiativeEquals          = (initiative == anotherState.initiative);
            bool initiativeReferenceEquals = object.ReferenceEquals(initiative, anotherState.initiative);

            bool scaredEquals          = (scared == anotherState.scared);
            bool scaredReferenceEquals = object.ReferenceEquals(scared, anotherState.scared);

            bool angryAtEquals          = angryAt.Equals(anotherState.angryAt);
            bool angryAtReferenceEquals = object.ReferenceEquals(angryAt, anotherState.angryAt);

            bool wantsToGoEquals;
            bool wantsToGoReferenceEquals;

            if (wantsToGo == null && anotherState.wantsToGo == null)
            {
                wantsToGoEquals          = true;
                wantsToGoReferenceEquals = true;
            }
            else
            {
                wantsToGoEquals          = wantsToGo.Equals(anotherState.wantsToGo);
                wantsToGoReferenceEquals = object.ReferenceEquals(wantsToGo, anotherState.wantsToGo);
            }

            bool wantToEntrapEquals          = wantToEntrap.Equals(anotherState.wantToEntrap);
            bool wantToEntrapReferenceEquals = object.ReferenceEquals(wantToEntrap, anotherState.wantToEntrap);

            bool talkingWithEquals          = talkingWith.Equals(anotherState.talkingWith);
            bool talkingWithReferenceEquals = object.ReferenceEquals(talkingWith, anotherState.talkingWith);

            bool skipedTurnsEquals          = (skipedTurns == anotherState.skipedTurns);
            bool skipedTurnsReferenceEquals = object.ReferenceEquals(skipedTurns, anotherState.skipedTurns);

            bool beliefsEquals          = beliefs.Equals(anotherState.beliefs);
            bool beliefsReferenceEquals = object.ReferenceEquals(beliefs, anotherState.beliefs);

            bool foundEvidenceEquals          = foundEvidence.Equals(anotherState.foundEvidence);
            bool foundEvidenceReferenceEquals = object.ReferenceEquals(foundEvidence, anotherState.foundEvidence);

            bool exploredRoomsEquals          = true;
            bool exploredRoomsReferenceEquals = true;

            if (exploredRooms.Count == anotherState.exploredRooms.Count)
            {
                for (int i = 0; i < exploredRooms.Count; i++)
                {
                    if (!exploredRooms.ElementAt(i).Equals(anotherState.exploredRooms.ElementAt(i)))
                    {
                        exploredRoomsEquals = false;
                    }
                    if (!object.ReferenceEquals(exploredRooms.ElementAt(i), anotherState.exploredRooms.ElementAt(i)))
                    {
                        exploredRoomsReferenceEquals = false;
                    }
                }
            }
            else
            {
                exploredRoomsEquals          = false;
                exploredRoomsReferenceEquals = false;
            }

            bool agentInfoGlobal     = agentInfoEquals || agentInfoReferenceEquals;
            bool statusGlobal        = statusEquals || statusReferenceEquals;
            bool goalsGlobal         = goalsEquals || goalsReferenceEquals;
            bool initiativeGlobal    = initiativeEquals || initiativeReferenceEquals;
            bool scaredGlobal        = scaredEquals || scaredReferenceEquals;
            bool angryAtGlobal       = angryAtEquals || angryAtReferenceEquals;
            bool wantToGoGlobal      = wantsToGoEquals || wantsToGoReferenceEquals;
            bool wantToEntrapGlobal  = wantToEntrapEquals || wantToEntrapReferenceEquals;
            bool talkingWithGlobal   = talkingWithEquals || talkingWithReferenceEquals;
            bool skipedTurnsGlobal   = skipedTurnsEquals || skipedTurnsReferenceEquals;
            bool beliefsGlobal       = beliefsEquals || beliefsReferenceEquals;
            bool foundEvidenceGlobal = foundEvidenceEquals || foundEvidenceReferenceEquals;
            bool exploredRoomsGlobal = exploredRoomsEquals || exploredRoomsReferenceEquals;

            bool equal = agentInfoGlobal && statusGlobal && goalsGlobal && initiativeGlobal && scaredGlobal && angryAtGlobal && wantToGoGlobal &&
                         wantToEntrapGlobal && talkingWithGlobal && skipedTurnsGlobal && beliefsGlobal && foundEvidenceGlobal && exploredRoomsGlobal;

            return(equal);
        }