|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.vizzini.game.AbstractEnvironment
org.vizzini.game.boardgame.AbstractGridBoard
public abstract class AbstractGridBoard
Provides functionality for 2D and 3D grid board environments in the game framework.
| Field Summary | |
|---|---|
protected static UndoAction |
UNDO_ACTION
Undo action. |
| Constructor Summary | |
|---|---|
AbstractGridBoard()
|
|
| Method Summary | |
|---|---|
int |
agentTokenCount(IAgent agent,
int startF,
int startR,
int startL,
int df,
int dr,
int dl)
Return the number of token's the given agent has in the line specified by the other arguments. |
void |
configure(Properties properties)
Configure this environment. |
int |
coordsToIndex(int file,
int rank,
int level)
Return the index computed from the given parameters. |
void |
copy(IEnvironment environment)
Copy data from the given instance into this. |
IToken |
get(int file,
int rank,
int level)
Return the token at the given position. |
int |
getCellCount()
Return the cell count. |
IAgent |
getCurrentAgent()
Return the current agent. |
int |
getFileCount()
Return the file count. |
IAgent |
getLastAgent()
Return the last agent who performed an action. |
int |
getLevelCount()
Return the level count. |
int |
getMaxDimension()
Return the maximum of the file, rank, and level counts. |
int |
getRankCount()
Return the rank count. |
int |
indexToFile(int index)
Return the file coordinates computed from the given index. |
int |
indexToLevel(int index)
Return the level coordinates computed from the given index. |
IntegerPosition |
indexToPosition(int index)
Return the position computed from the given index. |
int |
indexToRank(int index)
Return the rank coordinates computed from the given index. |
boolean |
is3D()
Return true if this is using 3D coordinates. |
boolean |
isActionHistoryUsed()
|
boolean |
isPositionUsable(IntegerPosition position)
Return true if the given position is usable. |
boolean |
isPositionUsable(int file,
int rank,
int level)
Return true if the given position is usable. |
boolean |
isRedoAllowed()
Return true if a redo action is allowed. |
boolean |
isUndoAllowed()
Return true if an undo action is allowed. |
void |
performAction(IAction action)
Perform the given action. |
int |
positionToIndex(IntegerPosition position)
Return the index computed from the given position. |
void |
setActionHistoryUsed(boolean isActionHistoryUsed)
|
protected void |
setLastAgent(IAgent agent)
Set the last agent who performed an action. |
void |
setToken(IntegerPosition position,
IToken token)
Set the token at the given position. |
void |
setToken(int file,
int rank,
int level,
IToken token)
Set the token at the given position. |
void |
undoAction(IAction action)
Undo the given action. |
| Methods inherited from class org.vizzini.game.AbstractEnvironment |
|---|
addStateListener, clone, createInitialTokens, equals, get, getAdjudicator, getAgentCollection, getStateManager, getTeamCollection, getTokenCollection, getTokenCollectionClass, getTurnNumber, hashCode, incrementTurnNumber, isFiringStateChanges, open, performActions, removeStateListener, reset, setAdjudicator, setAgentCollection, setFiringStateChanges, setTokenCollectionClass, setTurnNumber, update |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.vizzini.game.IEnvironment |
|---|
addStateListener, clone, get, getAdjudicator, getAgentCollection, getTeamCollection, getTokenCollection, getTurnNumber, incrementTurnNumber, isFiringStateChanges, open, performActions, removeStateListener, reset, setAdjudicator, setAgentCollection, setFiringStateChanges, setTurnNumber, update |
| Field Detail |
|---|
protected static final UndoAction UNDO_ACTION
| Constructor Detail |
|---|
public AbstractGridBoard()
| Method Detail |
|---|
public int agentTokenCount(IAgent agent,
int startF,
int startR,
int startL,
int df,
int dr,
int dl)
There are many possible lines:
files: rl
ranks: fl
levels: fr
file diagonals: 2f
rank diagonals: 2r
level diagonals: 2l
triagonals: 4
total: rl + rl + fr + 2f + 2r + 2l + 4
Example: f = r = l = 4
16 + 16 + 16 + 8 + 8 + 8 + 4 = 48 + 24 + 4 = 76
agentTokenCount in interface IGridBoardagent - Agent of interest.startF - Starting file.startR - Starting rank.startL - Starting level.df - Delta in the file direction.dr - Delta in the rank direction.dl - Delta in the level direction.
public void configure(Properties properties)
throws InstantiationException,
IllegalAccessException
configure in interface IEnvironmentconfigure in class AbstractEnvironmentproperties - Source of configuration information.
InstantiationException
IllegalAccessException
public int coordsToIndex(int file,
int rank,
int level)
coordsToIndex in interface IGridBoardfile - File.rank - Rank.level - Level.
public void copy(IEnvironment environment)
copy in interface IEnvironmentcopy in class AbstractEnvironmentenvironment - Environment from which to copy data.
public IToken get(int file,
int rank,
int level)
get in interface IGridBoardfile - File.rank - Rank.level - Level.public int getCellCount()
getCellCount in interface IGridBoardpublic IAgent getCurrentAgent()
public int getFileCount()
getFileCount in interface IGridBoardpublic IAgent getLastAgent()
getLastAgent in interface IGridBoardpublic int getLevelCount()
getLevelCount in interface IGridBoardpublic int getMaxDimension()
getMaxDimension in interface IGridBoardpublic int getRankCount()
getRankCount in interface IGridBoardpublic int indexToFile(int index)
indexToFile in interface IGridBoardindex - Index.public int indexToLevel(int index)
indexToLevel in interface IGridBoardindex - Index.public IntegerPosition indexToPosition(int index)
indexToPosition in interface IGridBoardindex - Index.public int indexToRank(int index)
indexToRank in interface IGridBoardindex - Index.public boolean is3D()
is3D in interface IGridBoardpublic boolean isActionHistoryUsed()
isActionHistoryUsed in interface IGridBoardpublic boolean isPositionUsable(IntegerPosition position)
isPositionUsable in interface IGridBoardposition - Position.
public boolean isPositionUsable(int file,
int rank,
int level)
isPositionUsable in interface IGridBoardpublic boolean isRedoAllowed()
isRedoAllowed in interface IGridBoardpublic boolean isUndoAllowed()
isUndoAllowed in interface IGridBoardpublic void performAction(IAction action)
performAction in interface IEnvironmentaction - Action.
ClassCastException - if action0 is not a
PlacementAction.public int positionToIndex(IntegerPosition position)
positionToIndex in interface IGridBoardposition - Position.public void setActionHistoryUsed(boolean isActionHistoryUsed)
setActionHistoryUsed in interface IGridBoardisActionHistoryUsed - The isActionHistoryUsed to set.
public void setToken(IntegerPosition position,
IToken token)
setToken in interface IGridBoardposition - Position.token - Token.
public void setToken(int file,
int rank,
int level,
IToken token)
setToken in interface IGridBoardfile - File.rank - Rank.level - Level.token - Token.public void undoAction(IAction action)
undoAction in interface IEnvironmentaction - Action.
ClassCastException - if action0 is not a
PlacementAction.protected void setLastAgent(IAgent agent)
agent - Agent.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
| Copyright © 2007 Vizzini.org. All Rights Reserved. | 2007.12.25.03.00.02 |