org.mars_sim.msp.simulation.person.ai.social
Class RelationshipManager

java.lang.Object
  extended by org.mars_sim.msp.simulation.person.ai.social.RelationshipManager
All Implemented Interfaces:
java.io.Serializable

public class RelationshipManager
extends java.lang.Object
implements java.io.Serializable

The RelationshipManager class keeps track of all the social relationships between people. The simulation instance has only one relationship manager.

See Also:
Serialized Form

Constructor Summary
RelationshipManager()
          Constructor
 
Method Summary
 void addInitialSettler(Person person, Settlement settlement)
          Adds an innitial settler who will have an existing relationship with all the other inhabitants if his/her settlement.
 void addNewImmigrant(Person person, java.util.Collection<Person> immigrantGroup)
          Adds a new resupply immigrant who will have an existing relationship with the other immigrants in his/her group.
 void addRelationship(Person person1, Person person2, java.lang.String relationshipType)
          Adds a new relationship between two people.
 java.util.Collection<Person> getAllKnownPeople(Person person)
          Gets all the people that a person knows (has met).
 java.util.List getAllRelationships(Person person)
          Gets all of a person's relationships.
 double getAverageOpinionOfPeople(Person person1, java.util.Collection<Person> people)
          Gets the average opition that a person has of a group of people.
 double getOpinionOfPerson(Person person1, Person person2)
          Gets the opinion that a person has of another person.
 Relationship getRelationship(Person person1, Person person2)
          Gets the relationship between two people.
 boolean hasRelationship(Person person1, Person person2)
          Checks if a person has a relationship with another person.
 void timePassing(Person person, double time)
          Time passing for a person's relationships.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelationshipManager

public RelationshipManager()
Constructor

Method Detail

addInitialSettler

public void addInitialSettler(Person person,
                              Settlement settlement)
Adds an innitial settler who will have an existing relationship with all the other inhabitants if his/her settlement.

Parameters:
person - the person to add.
settlement - the settlement the person starts at.

addNewImmigrant

public void addNewImmigrant(Person person,
                            java.util.Collection<Person> immigrantGroup)
Adds a new resupply immigrant who will have an existing relationship with the other immigrants in his/her group.

Parameters:
person - the person to add.
immigrantGroup - the groups of immigrants this person belongs to.

addRelationship

public void addRelationship(Person person1,
                            Person person2,
                            java.lang.String relationshipType)
Adds a new relationship between two people.

Parameters:
person1 - the first person (order isn't important)
person2 - the second person (order isn't important)
relationshipType - the type of relationship (see Relationship static members)

hasRelationship

public boolean hasRelationship(Person person1,
                               Person person2)
Checks if a person has a relationship with another person.

Parameters:
person1 - the first person (order isn't important)
person2 - the second person (order isn't important)
Returns:
true if the two people have a relationship

getRelationship

public Relationship getRelationship(Person person1,
                                    Person person2)
Gets the relationship between two people.

Parameters:
person1 - the first person (order isn't important)
person2 - the second person (order isn't important)
Returns:
the relationship or null if none.

getAllRelationships

public java.util.List getAllRelationships(Person person)
Gets all of a person's relationships.

Parameters:
person - the person
Returns:
a list of the person's Relationship objects.

getAllKnownPeople

public java.util.Collection<Person> getAllKnownPeople(Person person)
Gets all the people that a person knows (has met).

Parameters:
person - the person
Returns:
a list of the people the person knows.

getOpinionOfPerson

public double getOpinionOfPerson(Person person1,
                                 Person person2)
Gets the opinion that a person has of another person. Note: If the people don't have a relationship, return default value of 50.

Parameters:
person1 - the person holding the opinion.
person2 - the person who the opinion is of.
Returns:
opinion value from 0 (enemy) to 50 (indifferent) to 100 (close friend).

getAverageOpinionOfPeople

public double getAverageOpinionOfPeople(Person person1,
                                        java.util.Collection<Person> people)
Gets the average opition that a person has of a group of people. Note: If person1 doesn't have a relationship with any of the people, return default value of 50.

Parameters:
person1 - the person holding the opinion.
people - the collection of people who the opinion is of.
Returns:
opinion value from 0 (enemy) to 50 (indifferent) to 100 (close friend).

timePassing

public void timePassing(Person person,
                        double time)
                 throws java.lang.Exception
Time passing for a person's relationships.

Parameters:
person - the person
time - the time passing (millisols)
Throws:
java.lang.Exception - if error.