public class TitForTat extends SGAgent
Modifier and Type | Class and Description |
---|---|
static class |
TitForTat.TitForTatAgentFactory
An agent factory for a TitForTat player.
|
Modifier and Type | Field and Description |
---|---|
protected SGAgentAction |
lastOpponentMove
The last opponent's move
|
protected SGAgentAction |
myCoop
This agent's cooperate action
|
protected SGAgentAction |
myDefect
This agent's defect action
|
protected SGAgentAction |
opponentCoop
The opponent's cooperate action
|
protected SGAgentAction |
opponentDefect
The opponent's defect action
|
agentType, domain, internalRewardFunction, world, worldAgentName
Constructor and Description |
---|
TitForTat(SGDomain domain,
SGAgentAction coop,
SGAgentAction defect)
Initializes with the specified cooperate and defect actions for both players.
|
TitForTat(SGDomain domain,
SGAgentAction myCoop,
SGAgentAction myDefect,
SGAgentAction opponentCoop,
SGAgentAction opponentDefect)
Initializes with differently specified cooperate and defect actions for both players.
|
Modifier and Type | Method and Description |
---|---|
void |
gameStarting()
This method is called by the world when a new game is starting.
|
void |
gameTerminated()
This method is called by the world when a game has ended.
|
GroundedSGAgentAction |
getAction(State s)
This method is called by the world when it needs the agent to choose an action
|
void |
observeOutcome(State s,
JointAction jointAction,
java.util.Map<java.lang.String,java.lang.Double> jointReward,
State sprime,
boolean isTerminal)
This method is called by the world when every agent in the world has taken their action.
|
getAgentName, getAgentType, getInternalRewardFunction, init, joinWorld, setInternalRewardFunction
protected SGAgentAction myCoop
protected SGAgentAction myDefect
protected SGAgentAction opponentCoop
protected SGAgentAction opponentDefect
protected SGAgentAction lastOpponentMove
public TitForTat(SGDomain domain, SGAgentAction coop, SGAgentAction defect)
domain
- the domain in which this agent will play.coop
- the cooperate action for both playersdefect
- the defect action for both playerspublic TitForTat(SGDomain domain, SGAgentAction myCoop, SGAgentAction myDefect, SGAgentAction opponentCoop, SGAgentAction opponentDefect)
domain
- the domain in which this agent will playmyCoop
- this agent's cooperate actionmyDefect
- this agent's defect actionopponentCoop
- the opponent's cooperate actionopponentDefect
- the opponent's defect actionpublic void gameStarting()
SGAgent
gameStarting
in class SGAgent
public GroundedSGAgentAction getAction(State s)
SGAgent
public void observeOutcome(State s, JointAction jointAction, java.util.Map<java.lang.String,java.lang.Double> jointReward, State sprime, boolean isTerminal)
SGAgent
observeOutcome
in class SGAgent
s
- the state in which the last action of each agent was takenjointAction
- the joint action of all agents in the worldjointReward
- the joint reward of all agents in the worldsprime
- the next state to which the agent transitionedisTerminal
- whether the new state is a terminal statepublic void gameTerminated()
SGAgent
gameTerminated
in class SGAgent