public class TitForTat extends SGAgentBase
Modifier and Type | Class and Description |
---|---|
static class |
TitForTat.TitForTatAgentFactory
An agent factory for a TitForTat player.
|
Modifier and Type | Field and Description |
---|---|
protected int |
agentNum |
protected Action |
lastOpponentMove
The last opponent's move
|
protected Action |
myCoop
This agent's cooperate action
|
protected Action |
myDefect
This agent's defect action
|
protected Action |
opponentCoop
The opponent's cooperate action
|
protected Action |
opponentDefect
The opponent's defect action
|
protected int |
otherNum |
agentType, domain, internalRewardFunction, world, worldAgentName
Constructor and Description |
---|
TitForTat(SGDomain domain,
Action coop,
Action defect)
Initializes with the specified cooperate and defect actions for both players.
|
TitForTat(SGDomain domain,
Action myCoop,
Action myDefect,
Action opponentCoop,
Action opponentDefect)
Initializes with differently specified cooperate and defect actions for both players.
|
Modifier and Type | Method and Description |
---|---|
Action |
action(State s)
This method is called by the world when it needs the agent to choose an action
|
void |
gameStarting(World w,
int agentNum)
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.
|
void |
observeOutcome(State s,
JointAction jointAction,
double[] jointReward,
State sprime,
boolean isTerminal)
This method is called by the world when every agent in the world has taken their action.
|
agentName, agentType, getInternalRewardFunction, init, init, setAgentDetails, setInternalRewardFunction
protected Action myCoop
protected Action myDefect
protected Action opponentCoop
protected Action opponentDefect
protected Action lastOpponentMove
protected int agentNum
protected int otherNum
public TitForTat(SGDomain domain, Action coop, Action 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, Action myCoop, Action myDefect, Action opponentCoop, Action 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(World w, int agentNum)
SGAgent
w
- the world in which the game is startingagentNum
- the agent number of the agent in the worldpublic Action action(State s)
SGAgent
s
- the current state of the worldpublic void observeOutcome(State s, JointAction jointAction, double[] jointReward, State sprime, boolean isTerminal)
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