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); }
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); }