edu.columbia.cs.coms4701.agent.environments.pente
Class PenteEnvironment

java.lang.Object
  extended by edu.columbia.cs.coms4701.agent.environments.simple.AbstractEnvironment<K,P,A>
      extended by edu.columbia.cs.coms4701.agent.environments.grid.AbstractGridEnvironment<PenteAction,PentePercept,PenteAgent>
          extended by edu.columbia.cs.coms4701.agent.environments.pente.PenteEnvironment
All Implemented Interfaces:
Environment<PenteAction,PentePercept,PenteAgent>, GridEnvironment<PenteAction,PentePercept,PenteAgent>

public class PenteEnvironment
extends AbstractGridEnvironment<PenteAction,PentePercept,PenteAgent>
implements GridEnvironment<PenteAction,PentePercept,PenteAgent>

The Pente game environment.

Version:
0.1

User: aaron Date: Sep 24, 2006 Time: 5:13:27 PM

Author:
aaron@cs

Field Summary
 
Fields inherited from class edu.columbia.cs.coms4701.agent.environments.grid.AbstractGridEnvironment
map
 
Fields inherited from class edu.columbia.cs.coms4701.agent.environments.simple.AbstractEnvironment
agents, counter, environmentObjects, environmentObservers
 
Constructor Summary
PenteEnvironment()
          Constructs a new PenteEnvironment that will be of the given size.
PenteEnvironment(PenteRules theRules)
          Constructs a new PenteEnvironment that will be of the given size and use the given rules.
 
Method Summary
 void addEnvironmentObject(EnvironmentObject theObject)
          Customized to track the rules
 void agentDrivenChange(PenteAgent theAgent, PenteAction theAction)
          Changes the state of zero or more environment objects, given an agent and the action that the agent selected.
 void dynamicChange()
          Customized to do the random assignment of turns
 void executeStep()
          Performs one step of the simulated environment.
 void initialSetup()
          Does the initial setup of the Pente environment.
 java.util.Set<PentePercept> perceptsForAgent(PenteAgent theAgent)
          Returns a set (possibly empty) of percepts for the given agent.
 void startingToRunSetup()
          Default first-run initialization.
 void updatePerformanceMeasures()
           
 
Methods inherited from class edu.columbia.cs.coms4701.agent.environments.grid.AbstractGridEnvironment
getMap
 
Methods inherited from class edu.columbia.cs.coms4701.agent.environments.simple.AbstractEnvironment
addAgent, addEnvironmentObserver, getAgents, getCounter, getEnvironmentObjects, isDone, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.columbia.cs.coms4701.agent.environments.grid.GridEnvironment
getMap
 
Methods inherited from interface edu.columbia.cs.coms4701.agent.Environment
addAgent, addEnvironmentObserver, getAgents, getCounter, getEnvironmentObjects, isDone, run
 

Constructor Detail

PenteEnvironment

public PenteEnvironment()
Constructs a new PenteEnvironment that will be of the given size. The board is always a square.

Note that the environment's GridMap is not actually constructed until #initialSetup is invoked. This permits observers to be attached first.


PenteEnvironment

public PenteEnvironment(PenteRules theRules)
Constructs a new PenteEnvironment that will be of the given size and use the given rules. The board is always a square.

Note that the environment's GridMap is not actually constructed until #initialSetup is invoked. This permits observers to be attached first.

Method Detail

initialSetup

public void initialSetup()
Does the initial setup of the Pente environment.

Specified by:
initialSetup in interface Environment<PenteAction,PentePercept,PenteAgent>
Overrides:
initialSetup in class AbstractEnvironment<PenteAction,PentePercept,PenteAgent>

startingToRunSetup

public void startingToRunSetup()
Description copied from class: AbstractEnvironment
Default first-run initialization. Default version does nothing.

Specified by:
startingToRunSetup in interface Environment<PenteAction,PentePercept,PenteAgent>
Overrides:
startingToRunSetup in class AbstractEnvironment<PenteAction,PentePercept,PenteAgent>

addEnvironmentObject

public void addEnvironmentObject(EnvironmentObject theObject)
Customized to track the rules

Specified by:
addEnvironmentObject in interface Environment<PenteAction,PentePercept,PenteAgent>
Overrides:
addEnvironmentObject in class AbstractGridEnvironment<PenteAction,PentePercept,PenteAgent>
Parameters:
theObject -

executeStep

public void executeStep()
Performs one step of the simulated environment.

i.e.

  1. dynamicChange(), which changes zero or more objects spontaneously
  2. for agent in agents: p = perceptsForAgent(agent), which returns the set of percepts for the specified agent given the current state of the objects.
  3. action = agent.nextAction(p), which fetches the agent's chosen action
  4. agentDrivenChange(agent,action), which changes zero or more objects

This is customized for the Pente environment, because we need to

Specified by:
executeStep in interface Environment<PenteAction,PentePercept,PenteAgent>
Overrides:
executeStep in class AbstractEnvironment<PenteAction,PentePercept,PenteAgent>

dynamicChange

public void dynamicChange()
Customized to do the random assignment of turns

Specified by:
dynamicChange in interface Environment<PenteAction,PentePercept,PenteAgent>
Overrides:
dynamicChange in class AbstractEnvironment<PenteAction,PentePercept,PenteAgent>

updatePerformanceMeasures

public void updatePerformanceMeasures()

perceptsForAgent

public java.util.Set<PentePercept> perceptsForAgent(PenteAgent theAgent)
Returns a set (possibly empty) of percepts for the given agent. Presumably, this method examines the state of environment objects (including the agent itself) to select the appropriate percept. Note that the percept might include the outcome of the agent's most recent action.

Specified by:
perceptsForAgent in interface Environment<PenteAction,PentePercept,PenteAgent>
Specified by:
perceptsForAgent in class AbstractEnvironment<PenteAction,PentePercept,PenteAgent>

agentDrivenChange

public void agentDrivenChange(PenteAgent theAgent,
                              PenteAction theAction)
Changes the state of zero or more environment objects, given an agent and the action that the agent selected.

This might involve changing the state of the agent, updating a map of locations, and updating a table of performance measures.

Specified by:
agentDrivenChange in interface Environment<PenteAction,PentePercept,PenteAgent>
Specified by:
agentDrivenChange in class AbstractEnvironment<PenteAction,PentePercept,PenteAgent>
Parameters:
theAgent - the agent that just selected an action
theAction - the action selected