dk.brics.bisim.model
Class GameModel

java.lang.Object
  extended by dk.brics.bisim.model.GameModel

public class GameModel
extends java.lang.Object

A local game model holding two GrappaModels. It also holds the state space and configuration graph of the combined states. This is used by AIs but also to detect infinite games, in which case the defender is declared winner. In practice, we do not wish to wait forever, so we define an infinite game as returning to an already seen configuration (s,t) of nodes from the left and right LTS respectively. This can be justified by the fact that a perfect attacker can always avoid returning to a previously visited state.

Author:
Martin Mosegaard martinm@daimi.au.dk

Field Summary
private  java.lang.String attackerAction
           
private  int attackerSide
           
private  ConfigurationGraph configurationGraph
           
static int FINITE_GAME
           
private  boolean gameOver
           
private  boolean hasStateSpacePartition
           
private  int infiniteGameOver
           
static int LEFT_SIDE
           
private  LTSModel leftLTSModel
           
static int NOBODYS_TURN
           
static int RIGHT_SIDE
           
private  LTSModel rightLTSModel
           
private  int roundNumber
           
private  java.util.ArrayList<CGNode> seenConfigurations
           
private  StateSpace stateSpace
           
private  int turn
           
static int TURN_ATTACKER_1
           
static int TURN_ATTACKER_2
           
static int TURN_DEFENDER
           
 
Constructor Summary
GameModel(java.lang.String leftInitialNodeName, java.lang.String rightInitialNodeName)
           
 
Method Summary
 void buildStateSpace()
          Create a state space, partition it, and create a corresponding configuration graph.
 java.lang.String getAttackerAction()
           
 int getAttackerSide()
           
 ConfigurationGraph getConfigurationGraph()
           
 int getInfiniteGameOver()
           
 LTSModel getLeftLTSModel()
           
 LTSModel getRightLTSModel()
           
 StateSpace getStateSpace()
           
 int getTurn()
           
 boolean hasStateSpacePartition()
           
 int incAndGetRoundNumber()
           
 boolean isGameOver()
           
 void reset()
          Reset LTS models.
private  void resetSeenConfigurations()
          Reset the set of seen configurations and add the initial configuration.
 void setAttackerAction(java.lang.String attackerAction)
          Sets the attackers action
 void setAttackerSide(int attackerSide)
          Sets the attacker side.
 void setGameOver()
          Calculates if game is over.
 void setTurn(int turn)
          Sets the turn (attacker/defender)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FINITE_GAME

public static final int FINITE_GAME
See Also:
Constant Field Values

NOBODYS_TURN

public static final int NOBODYS_TURN
See Also:
Constant Field Values

TURN_ATTACKER_1

public static final int TURN_ATTACKER_1
See Also:
Constant Field Values

TURN_ATTACKER_2

public static final int TURN_ATTACKER_2
See Also:
Constant Field Values

TURN_DEFENDER

public static final int TURN_DEFENDER
See Also:
Constant Field Values

LEFT_SIDE

public static final int LEFT_SIDE
See Also:
Constant Field Values

RIGHT_SIDE

public static final int RIGHT_SIDE
See Also:
Constant Field Values

turn

private int turn

attackerSide

private int attackerSide

roundNumber

private int roundNumber

attackerAction

private java.lang.String attackerAction

leftLTSModel

private LTSModel leftLTSModel

rightLTSModel

private LTSModel rightLTSModel

gameOver

private boolean gameOver

infiniteGameOver

private int infiniteGameOver

stateSpace

private StateSpace stateSpace

hasStateSpacePartition

private boolean hasStateSpacePartition

configurationGraph

private ConfigurationGraph configurationGraph

seenConfigurations

private java.util.ArrayList<CGNode> seenConfigurations
Constructor Detail

GameModel

public GameModel(java.lang.String leftInitialNodeName,
                 java.lang.String rightInitialNodeName)
Method Detail

buildStateSpace

public void buildStateSpace()
Create a state space, partition it, and create a corresponding configuration graph.


getAttackerAction

public java.lang.String getAttackerAction()
Returns:
The attackers last chosen action

setAttackerAction

public void setAttackerAction(java.lang.String attackerAction)
Sets the attackers action

Parameters:
attackerAction - An action

getTurn

public int getTurn()
Returns:
The turn (attacker/defender)

setTurn

public void setTurn(int turn)
Sets the turn (attacker/defender)

Parameters:
turn - A turn

getAttackerSide

public int getAttackerSide()
Returns:
The current attacker side

setAttackerSide

public void setAttackerSide(int attackerSide)
Sets the attacker side.

Parameters:
attackerSide - A side

getLeftLTSModel

public LTSModel getLeftLTSModel()
Returns:
The grappa model of the left LTS

getRightLTSModel

public LTSModel getRightLTSModel()
Returns:
The grappa model of the right LTS

reset

public void reset()
Reset LTS models.


resetSeenConfigurations

private void resetSeenConfigurations()
Reset the set of seen configurations and add the initial configuration.


isGameOver

public boolean isGameOver()
Returns:
Game over status

getInfiniteGameOver

public int getInfiniteGameOver()
Returns:
If an infinite game has been won by the defender

setGameOver

public void setGameOver()
Calculates if game is over.


incAndGetRoundNumber

public int incAndGetRoundNumber()

getStateSpace

public StateSpace getStateSpace()

getConfigurationGraph

public ConfigurationGraph getConfigurationGraph()

hasStateSpacePartition

public boolean hasStateSpacePartition()