|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectknockabout.gamemodel.Board
The Knockabout GameBoard main data struct is simply of a double-array of Hexes.
Due to the shape of the board (see game pics on website), not every element
in the array represents a valid board position. We can use the isValidCoord
method to verify that an (x,y) position on the gameboard is valid.
uses the coordinate system as depicted on http://www.gamerz.net/pbmserv/hexxagon.html
I say we scrap the use of letters and start at 0 on each side. With x's on the left and
y's on the topright as so (o's represent the gutter):
0 1 2 3 4 5 6
/ / / / / / / 7
0- o o o o o o o / 8 y
1- o . . . . . . o / 9
x 2- o . . . . . . . o / 10
3- o . . . . . . . . o / 11
4- o . . . . . . . . . o / 12
5- o . . . . . . . . . . o /
6- o . . . . . . . . . . . o
7- o . . . . . . . . z . o <--- that 'z' is at loc (x,y) = (7,10)
8- o . . . . . . . . . o
9- o . . . . . . . . o
10- o . . . . . . . o
11- o . . . . . . o
12- o o o o o o o
- mutable data type
- the starting position is as follows:
initial face-up values:
all four-sided dice: 1
all six-sided dice: 2
all eight-sided dice: 3
positions:
(3,4) black d4
(3,5) yellow d4
(4,3) black d6
(4,7) yellow d6
(5,2) black d8
(5,5) black d4
(5,6) yellow d4
(5,9) yellow d8
(6,4) black d6)
(6,8) yellow d6
(7,3) black d8
(7,6) black d4
(7,7) yellow d4
(7,10) yellow d8
(8,5) black d6
(8,9) yellow d6
(9,7) black d4
(9,8) yellow d4
Field Summary | |
static int |
BOARDSIZE
|
Constructor Summary | |
Board()
New Instance of HexBoard (with dies at initial positions) |
|
Board(java.util.List initialDies)
New intance of HexBoard with specified initial condition |
Method Summary | |
Board |
deepclone()
Performs a deep clone of the board, including all underlying fields |
protected void |
empty()
Remove all dies from the board (not just put them in the gutter.. |
java.util.List |
getBlackDies()
|
Hex |
getHex(int x,
int y)
Returns the Hexagon located at Board coordinate (x,y). |
java.util.List |
getPieces(int color)
Access all the pieces of a given color |
java.util.List |
getPiecesNotInGutter(int color)
Get all the dies of a given color that are not in the gutter |
int |
getRemainingBlackD4()
|
int |
getRemainingBlackD6()
|
int |
getRemainingBlackD8()
|
int |
getRemainingBlackDies()
|
int |
getRemainingYellowD4()
|
int |
getRemainingYellowD6()
|
int |
getRemainingYellowD8()
|
int |
getRemainingYellowDies()
|
java.util.List |
getYellowDies()
|
static boolean |
inGutter(int x,
int y)
Is position (x,y) located in the Gutter area? |
static boolean |
isValidCoord(int x,
int y)
Is this (x,y) coordinate located on the Hex-Grid |
protected boolean |
isValidGutterMove(int x,
int y,
int dir)
|
protected boolean |
isValidGutterMove(Move m)
|
boolean |
isValidMove(Move move,
int playercolor)
Returns true if the given move by black or yellow player is a legal move, otherwise false |
void |
move(int x1,
int y1,
int x2,
int y2)
Moves a die from one hex at (x1,y1) to the position (x2,y2), updating all required fields |
static int |
nextDir(int x,
int y,
int dir)
|
static int |
nextX(int x,
int dir)
|
static int |
nextY(int y,
int dir)
|
protected void |
reloadWithDies(java.util.List dies)
|
protected void |
setBlackDies(java.util.List set)
|
protected void |
setRemainingBlackD4(int i)
|
protected void |
setRemainingBlackD6(int i)
|
protected void |
setRemainingBlackD8(int i)
|
protected void |
setRemainingBlackDies(int i)
|
protected void |
setRemainingYellowD4(int i)
|
protected void |
setRemainingYellowD6(int i)
|
protected void |
setRemainingYellowD8(int i)
|
protected void |
setRemainingYellowDies(int i)
|
protected void |
setYellowDies(java.util.List set)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int BOARDSIZE
Constructor Detail |
public Board(java.util.List initialDies)
initialDies
- A list of Dies object with initial informationpublic Board()
Method Detail |
protected void empty()
protected void reloadWithDies(java.util.List dies)
dies
- public static boolean inGutter(int x, int y)
public static boolean isValidCoord(int x, int y)
x
- y
- public void move(int x1, int y1, int x2, int y2)
public boolean isValidMove(Move move, int playercolor)
protected boolean isValidGutterMove(Move m)
protected boolean isValidGutterMove(int x, int y, int dir)
public Hex getHex(int x, int y)
public static int nextX(int x, int dir)
public static int nextY(int y, int dir)
public static int nextDir(int x, int y, int dir)
public Board deepclone()
public java.util.List getPieces(int color)
color
- The color code (see Player class)
public java.util.List getPiecesNotInGutter(int color)
color
- The color code (see Player class)
public java.util.List getBlackDies()
public java.util.List getYellowDies()
protected void setBlackDies(java.util.List set)
set
- protected void setYellowDies(java.util.List set)
set
- public int getRemainingBlackDies()
public int getRemainingYellowDies()
protected void setRemainingBlackDies(int i)
i
- protected void setRemainingYellowDies(int i)
i
- public java.lang.String toString()
public int getRemainingBlackD4()
public int getRemainingBlackD6()
public int getRemainingBlackD8()
public int getRemainingYellowD4()
public int getRemainingYellowD6()
public int getRemainingYellowD8()
protected void setRemainingBlackD4(int i)
i
- protected void setRemainingBlackD6(int i)
i
- protected void setRemainingBlackD8(int i)
i
- protected void setRemainingYellowD4(int i)
i
- protected void setRemainingYellowD6(int i)
i
- protected void setRemainingYellowD8(int i)
i
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |