|
|||||||||
| Home >> All >> cgsuite >> [ extras overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
cgsuite.extras
Class StaggerPosition

java.lang.Objectcgsuite.AbstractShortGame
cgsuite.extras.StaggerPosition
- All Implemented Interfaces:
- cgsuite.Game, java.io.Serializable
- public class StaggerPosition
- extends cgsuite.AbstractShortGame
An impartial grid game with one piece. It is played on a quarter-infinite board with edges at North and West. The piece can be oriented west or north. A move consists of advancing any (non-zero) number of squares in the direction the piece is pointing, then optionally changing the orientation. There are several rules variants we will check out that promise more interesting behaviour. (update 18/2): Michael says the variants have no more promise then the original. Oh well. There is no caching at present.
| Field Summary | |
private int |
north
west and north indicate the number of spaces left in that direction. |
static int |
NORTH
ints are most suitable for these because subclasses will need more than two orientations. |
private int |
orientation
west and north indicate the number of spaces left in that direction. |
private int |
west
west and north indicate the number of spaces left in that direction. |
static int |
WEST
ints are most suitable for these because subclasses will need more than two orientations. |
| Fields inherited from class cgsuite.AbstractShortGame |
|
| Fields inherited from interface cgsuite.Game |
SIMPLIFY_COOL, SIMPLIFY_FREEZE, SIMPLIFY_HEAT, SIMPLIFY_ORDINAL_SUM_G, SIMPLIFY_ORDINAL_SUM_H, SIMPLIFY_OVERHEAT, SIMPLIFY_PRODUCT_G, SIMPLIFY_PRODUCT_U, SIMPLIFY_SUM |
| Constructor Summary | |
StaggerPosition()
A default zero game. |
|
StaggerPosition(int west,
int north,
int orientation)
Basic constructor directly sets all fields (west, north, orientation). |
|
StaggerPosition(StaggerPosition from,
int move)
Move constructor with no direction change. |
|
StaggerPosition(StaggerPosition from,
int move,
int newOrient)
Move constructor with orientation change. |
|
StaggerPosition(java.lang.String in)
Human-readable (ish) string constructor. |
|
| Method Summary | |
int |
compareTo(java.lang.Object g)
Not sure if this is the intended way to do this. |
int |
getDist()
|
cgsuite.Game |
getInverse()
Impartial game, so it is its own inverse |
java.util.Collection |
getLeftOptions()
Impartial game, so left and right options are identical |
int |
getNorth()
|
int |
getOrientation()
Construct the int array representing this position. |
java.util.Collection |
getRightOptions()
Impartial game, so left and right options are identical |
int |
getWest()
|
boolean |
isValid()
Whether this represents a valid board position or not. |
boolean |
isValidMove(StaggerPosition to)
Check that the game given can be reached from the current game in exactly one move. |
java.lang.String |
toString()
Simple string representation. |
| Methods inherited from class cgsuite.AbstractShortGame |
canonicalize, isShortGame, simplify, simplifyExpression |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
west
private int west
- west and north indicate the number of spaces left in that
direction.
north
private int north
- west and north indicate the number of spaces left in that
direction.
orientation
private int orientation
- west and north indicate the number of spaces left in that
direction.
NORTH
public static final int NORTH
- ints are most suitable for these because subclasses will need
more than two orientations.
- See Also:
- Constant Field Values
WEST
public static final int WEST
- ints are most suitable for these because subclasses will need
more than two orientations.
- See Also:
- Constant Field Values
| Constructor Detail |
StaggerPosition
public StaggerPosition()
- A default zero game. Note that this is only one of many
possible zero games.
StaggerPosition
public StaggerPosition(int west,
int north,
int orientation)
- Basic constructor directly sets all fields (west, north,
orientation).
StaggerPosition
public StaggerPosition(StaggerPosition from, int move)
- Move constructor with no direction change.
No checking for a valid position: use isValid() on the result
to check.
StaggerPosition
public StaggerPosition(StaggerPosition from, int move, int newOrient)
- Move constructor with orientation change. Note that there is
no error checking. Use isValid() to test the result.
StaggerPosition
public StaggerPosition(java.lang.String in)
- Human-readable (ish) string constructor.
Format is "(w, n) o" where w and n are integer coordinates for
the position (from 0) and o is either '|' (north) or '-'
(west). All spaces and punctuation are optional, but the first
two fields must be separated.
To keep things simple at the moment, if you pass anything it
doesn't like it will print a message to stderr, and return a
zero game.
| Method Detail |
getOrientation
public int getOrientation()
- Construct the int array representing this position. It will
have zero entries on all spaces except the bottom right.
getWest
public int getWest()
getNorth
public int getNorth()
getDist
public int getDist()
isValid
public boolean isValid()
- Whether this represents a valid board position or not. It is
valid if the piece is on the board (west and north >= 0) and
the orientation is one of the valid ones.
isValidMove
public boolean isValidMove(StaggerPosition to)
- Check that the game given can be reached from the current game
in exactly one move. Thus isValidMove(this) returns false. This
also checks that the new position is valid.
toString
public java.lang.String toString()
- Simple string representation. Coordinates for the position
(west,north) then one of the two characters - and | for the
orientation. This format is also used for the string
constructor.
getLeftOptions
public java.util.Collection getLeftOptions()
- Impartial game, so left and right options are identical
getRightOptions
public java.util.Collection getRightOptions()
- Impartial game, so left and right options are identical
getInverse
public cgsuite.Game getInverse()
- Impartial game, so it is its own inverse
compareTo
public int compareTo(java.lang.Object g)
- Not sure if this is the intended way to do this. It's
presumably horribly inefficient. Is compareTo() intended for
use in the mathematical side of things, or the caching side?
|
|||||||||
| Home >> All >> cgsuite >> [ extras overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC