public class GrimTrigger extends Agent
gameStarting()
method is called again).Modifier and Type | Class and Description |
---|---|
static class |
GrimTrigger.GrimTriggerAgentFactory
An agent factory for GrimTrigger
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
grimTrigger
Whether this agent will play its defect action or not.
|
protected SingleAction |
myCoop
This agent's cooperate action
|
protected SingleAction |
myDefect
This agent's defect action
|
protected SingleAction |
opponentDefect
The opponent's defect action
|
agentType, domain, internalRewardFunction, world, worldAgentName
Constructor and Description |
---|
GrimTrigger(SGDomain domain,
SingleAction coop,
SingleAction defect)
Initializes with the specified cooperate and defect actions for both players.
|
GrimTrigger(SGDomain domain,
SingleAction myCoop,
SingleAction myDefect,
SingleAction 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.
|
GroundedSingleAction |
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 SingleAction myCoop
protected SingleAction myDefect
protected SingleAction opponentDefect
protected boolean grimTrigger
public GrimTrigger(SGDomain domain, SingleAction coop, SingleAction defect)
domain
- the domain in which this agent will play.coop
- the cooperate action for both playersdefect
- the defect action for both playerspublic GrimTrigger(SGDomain domain, SingleAction myCoop, SingleAction myDefect, SingleAction opponentDefect)
domain
- the domain in which this agent will playmyCoop
- this agent's cooperate actionmyDefect
- this agent's defect actionopponentDefect
- the opponent's defect actionpublic void gameStarting()
Agent
gameStarting
in class Agent
public GroundedSingleAction getAction(State s)
Agent
public void observeOutcome(State s, JointAction jointAction, java.util.Map<java.lang.String,java.lang.Double> jointReward, State sprime, boolean isTerminal)
Agent
observeOutcome
in class Agent
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()
Agent
gameTerminated
in class Agent