|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.cilib.games.states.GameState net.sourceforge.cilib.games.states.GridGameState
public class GridGameState
This is a GameState where all the GameItem's are stored in a matrix. For games like TickTackToe or Tetris storing all the gameItems in a list would not be desireable since accessing an item in a specific location in the grid would be much more complex.
Field Summary | |
---|---|
protected GameItem[][] |
state
|
Fields inherited from class net.sourceforge.cilib.games.states.GameState |
---|
currentIteration, randomizer |
Constructor Summary | |
---|---|
GridGameState()
|
|
GridGameState(GridGameState other)
Copy constructor |
|
GridGameState(int gridWidth,
int gridHeight)
|
Method Summary | |
---|---|
void |
clearState()
Clear the state and reset it to a start state. |
GridGameState |
getClone()
Create a cloned copy of the current object and return it. |
int |
getGridHeight()
|
int |
getGridWidth()
|
GameItem |
getItem(int i,
int j)
Get an Item at a specific index in the matrix. |
void |
setGridHeight(int gridHeight)
|
void |
setGridWidth(int gridWidth)
|
void |
setItem(int i,
int j,
GameItem item)
Set an item at a specific index in the matrix |
Methods inherited from class net.sourceforge.cilib.games.states.GameState |
---|
getCurrentIteration, getRandomizer, increaseIteration, resetIterationCount, setRandomizer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected GameItem[][] state
Constructor Detail |
---|
public GridGameState()
public GridGameState(int gridWidth, int gridHeight)
public GridGameState(GridGameState other)
other
- Method Detail |
---|
public int getGridHeight()
public void setGridHeight(int gridHeight)
public int getGridWidth()
public void setGridWidth(int gridWidth)
public GameItem getItem(int i, int j)
i
- the specified Columnj
- the specified Row
null
will be returned.public void setItem(int i, int j, GameItem item)
i
- the specified Columnj
- the specified Rowitem
- the item to set. This method does not check if an item already exists, and will simply override
what is in that position.public void clearState()
clearState
in class GameState
public GridGameState getClone()
getClone
in interface Cloneable
getClone
in class GameState
Object.clone()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |