public abstract class AgentImplementation extends java.util.Observable implements Agent
Modifier and Type | Field and Description |
---|---|
protected Agent |
currentVote
The suspicion who has the highest suspicious weight in current round
|
protected boolean |
eliminated
This boolean flag indicates if the agent has been eliminated
|
protected boolean |
mole
This boolean flag indicates if the agent is the mole.
|
protected java.lang.String |
nameString
Contains a string representation of this agent's name.
|
protected java.util.LinkedList<java.lang.String> |
ponderings
Contains ponderings.
|
protected java.util.HashMap<Agent,Agent> |
secondOrderBelief
One order belief history.
|
protected java.util.HashMap<Agent,java.lang.Double> |
suspicions
The suspicious weight.
|
protected java.lang.String |
typeString
The type of the agent, the default type is "plain contestant".
|
Constructor and Description |
---|
AgentImplementation()
Create an AgentImplementation.
|
AgentImplementation(java.lang.String agentName)
Creates an AgentImplementation with a specific name
|
Modifier and Type | Method and Description |
---|---|
void |
addCompetitor(Agent competitor)
Adds an competing Agent to this Agent's list of competitors
|
void |
addCompetitors(java.util.Collection<Agent> others)
Adds competitors to the current Agent class
|
protected double |
avgSuspicion()
Calculate average suspicion over all competitors
|
void |
clearSecondOrderBelief()
Clears this AgentImplementations second order beliefs.
|
protected void |
decideVote()
Makes the agent decide its vote.
|
void |
eliminate()
EliminationEvent tells the agent she is eliminated.
|
protected java.util.ArrayList<Agent> |
getMaxSuspiciousAgents()
Get the maximum suspicious agents list
|
java.lang.String |
getName()
What is this agent's name?
|
int |
getNumberOfCompetitors()
Returns the number of competitors this AgentImplementation has currently
|
java.util.LinkedList<java.lang.String> |
getPonderings()
Gets the most recent deep thoughts from this Agent
|
java.util.HashMap<Agent,java.lang.Double> |
getSuspicions()
Returns the current suspicion map
|
java.lang.String |
getTypeString()
Should return some String describing what this agent's type or intentions
are.
|
boolean |
isEliminated()
Am I eliminated?
|
boolean |
isMole()
Is this agent the mole?
|
void |
listenConversation(Agent speaker,
Agent suspicion)
ConversationEvent tells Agent who is the mole.
|
void |
normalizeSuspicions()
Normalizes the suspicions so they sum up to one.
|
protected void |
ponder(java.lang.String p)
Causes this agent to ponder something.
|
void |
setName(java.lang.String name) |
protected void |
setTypeString(java.lang.String s)
Sets the typestring, displayed in the GUI, to a specific String
|
protected double |
summedSuspicion()
Calculates the sum of all suspicions of this Agent, used by AvgSuspicion
and by normalizeSuspicion
|
Agent |
tellConversation()
This may do the same as vote
|
java.lang.String |
toString()
Returns the name of this agent
|
void |
updateSuspicion(Agent a,
double factor)
Multiply this AgentImplementation's suspicion towards a specific Agent
with some factor.
|
protected void |
updateView()
Update the view of agent.
|
Agent |
vote()
This is the voting method, used in the final stage of every game round.
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
doAssignment, informAssResult, informElimination, informGameEnd
protected java.lang.String nameString
protected boolean mole
protected boolean eliminated
protected java.util.HashMap<Agent,java.lang.Double> suspicions
protected java.util.HashMap<Agent,Agent> secondOrderBelief
protected java.util.LinkedList<java.lang.String> ponderings
protected Agent currentVote
protected java.lang.String typeString
public AgentImplementation()
public AgentImplementation(java.lang.String agentName)
agentName
- public java.util.LinkedList<java.lang.String> getPonderings()
protected void ponder(java.lang.String p)
p
- a String containing a deep thought.public Agent tellConversation()
Agent
tellConversation
in interface Agent
Agent.vote()
public void listenConversation(Agent speaker, Agent suspicion)
Agent
listenConversation
in interface Agent
speaker
- the agent who gives the informationsuspicion
- the suspicion which speaker tells listenerpublic void eliminate()
Agent
public boolean isEliminated()
Agent
isEliminated
in interface Agent
public void updateSuspicion(Agent a, double factor)
Agent
updateSuspicion
in interface Agent
a
- the agent towards whom the suspicion should be changedfactor
- the factor by which the suspicion should be changed. If the
factor is not positive it will be changed to 1, leaving the suspicion
unchanged.public void clearSecondOrderBelief()
public Agent vote()
Agent
protected void decideVote()
protected final java.util.ArrayList<Agent> getMaxSuspiciousAgents()
public void addCompetitor(Agent competitor)
Agent
addCompetitor
in interface Agent
competitor
- a new Agent to compete withpublic void addCompetitors(java.util.Collection<Agent> others)
Agent
addCompetitors
in interface Agent
others
- Collection with other Agentspublic boolean isMole()
Agent
public java.lang.String getName()
Agent
public void setName(java.lang.String name)
protected double avgSuspicion()
public void normalizeSuspicions()
Agent
normalizeSuspicions
in interface Agent
protected double summedSuspicion()
protected void updateView()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.HashMap<Agent,java.lang.Double> getSuspicions()
public java.lang.String getTypeString()
protected void setTypeString(java.lang.String s)
s
- the desired type describing string for this AgentImplementationpublic int getNumberOfCompetitors()