uchicago.src.repastdemos.enn
Class EnnAgent

java.lang.Object
  extended by uchicago.src.repastdemos.enn.EnnAgent
All Implemented Interfaces:
GameAgent, Drawable

public class EnnAgent
extends java.lang.Object
implements GameAgent, Drawable

A partial implementation of Randal Picker's Endogenous Neighborhood game as described in his as yet unpublished "Endogenous Neighborhoods and Norms." This simulation extends prior work by Randal Picker. See "Simple Games in a Complex World: A Generative Approach to the Adoption of Norms", 64 University of Chicago Law Review 1225 (1997). Thanks to Randal Picker for allowing us to include this with Repast. This agent plays a coordination game with its neighbors (if any). According its descision strategy an agent plays left or right each turn, calculates the payoffs, and decides what to do next turn.

Version:
$Revision: 1.1 $ $Date: 2005/08/12 20:04:51 $
Author:
Nick Collier and Randal Picker

Field Summary
static int CHANGE_FIRST
           
static int MOVE_AND_CHANGE
           
static int PURE_ASPIRATION
           
static int STRATEGY_UPGRADE
           
 
Fields inherited from interface uchicago.src.sim.games.GameAgent
LEFT, NULL, RIGHT
 
Constructor Summary
EnnAgent(int xValue, int yValue, int aspirationValue, int curStrategyValue, EnnGame game, Object2DTorus space, int contentStrategy, int discontentStrategy)
           
 
Method Summary
 void agentMove()
           
 void draw(SimGraphics g)
          Invoked when the object should draw itself
 int getAspiration()
           
 boolean getContent()
           
 int getCurStrategy()
           
 float getPayoff()
          Gets the current payoff for this agent.
 int getPrevStrategy()
           
 int getStrategy()
          Gets the current strategy (GameAgent.LEFT or GameAgent.RIGHT)
 int getX()
          Gets the x coordinate of this drawable.
 int getY()
          Gets the y coordinate of the this drawable.
 void makeStrategyDecision()
          Decide what (left or right) to play next turn depending on how payoff meets aspiration and what the agent's decision strategy is.
 void playGame()
          Performs the first part of agent's behavoir for this turn.
 void setAspiration(int aspirationValue)
           
 void setContent(boolean contentValue)
           
 void setCurStrategy(int curStrategyValue)
           
 void setPayoff(float payoff)
          Sets the payoff for this agent.
 void setPrevStrategy(int prevStrategyValue)
           
 void setStrategy(int newStrategy)
          Sets the current strategy (GameAgent.LEFT or GameAgent.RIGHT)
 void setX(int xValue)
           
 void setY(int yValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PURE_ASPIRATION

public static final int PURE_ASPIRATION
See Also:
Constant Field Values

STRATEGY_UPGRADE

public static final int STRATEGY_UPGRADE
See Also:
Constant Field Values

CHANGE_FIRST

public static final int CHANGE_FIRST
See Also:
Constant Field Values

MOVE_AND_CHANGE

public static final int MOVE_AND_CHANGE
See Also:
Constant Field Values
Constructor Detail

EnnAgent

public EnnAgent(int xValue,
                int yValue,
                int aspirationValue,
                int curStrategyValue,
                EnnGame game,
                Object2DTorus space,
                int contentStrategy,
                int discontentStrategy)
Method Detail

getPayoff

public float getPayoff()
Description copied from interface: GameAgent
Gets the current payoff for this agent.

Specified by:
getPayoff in interface GameAgent

getX

public int getX()
Description copied from interface: Drawable
Gets the x coordinate of this drawable. Note that this should return the x coordinate in some space, not necessarily a screen coordinate.

Specified by:
getX in interface Drawable

setX

public void setX(int xValue)

getY

public int getY()
Description copied from interface: Drawable
Gets the y coordinate of the this drawable. Note that this should return the y coordinate in some space, not necessarily a screen coordinate.

Specified by:
getY in interface Drawable

setY

public void setY(int yValue)

getContent

public boolean getContent()

setContent

public void setContent(boolean contentValue)

getAspiration

public int getAspiration()

setAspiration

public void setAspiration(int aspirationValue)

getCurStrategy

public int getCurStrategy()

setCurStrategy

public void setCurStrategy(int curStrategyValue)

getPrevStrategy

public int getPrevStrategy()

setPrevStrategy

public void setPrevStrategy(int prevStrategyValue)

playGame

public void playGame()
Performs the first part of agent's behavoir for this turn. This consists of playing the game, and calculating the payoff. The second part of the agents behavoir consists of comparing the payoff to the aspiration level and then performing the appropriate action based on that result and the agent's decision strategy.

An agent's action is broken up into two parts in order that all agent's play the same game on the same field. And then take action after all the agent's have played. Collapsing both parts into a "step()" method and calling that from the schedule means that each agent plays, then moves etc. and then the next agent plays etc.


makeStrategyDecision

public void makeStrategyDecision()
Decide what (left or right) to play next turn depending on how payoff meets aspiration and what the agent's decision strategy is.


agentMove

public void agentMove()

getStrategy

public int getStrategy()
Description copied from interface: GameAgent
Gets the current strategy (GameAgent.LEFT or GameAgent.RIGHT)

Specified by:
getStrategy in interface GameAgent

setPayoff

public void setPayoff(float payoff)
Description copied from interface: GameAgent
Sets the payoff for this agent.

Specified by:
setPayoff in interface GameAgent

setStrategy

public void setStrategy(int newStrategy)
Description copied from interface: GameAgent
Sets the current strategy (GameAgent.LEFT or GameAgent.RIGHT)

Specified by:
setStrategy in interface GameAgent

draw

public void draw(SimGraphics g)
Description copied from interface: Drawable
Invoked when the object should draw itself

Specified by:
draw in interface Drawable