|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--board
a board contains the current game situation: where the stones are, what color they have and who should move. It also contains a history so moves can be undone.
Field Summary | |
int[] |
A
the array A contains the stones. |
static int |
FREE
|
static int |
OUT
|
static int |
P1
|
static int |
P2
|
Constructor Summary | |
board()
|
Method Summary | |
boolean |
canmove(int c)
returns whether the current player is allowed to place a stone at c. |
void |
clear()
resetup the board to the initial situation. |
board |
copy()
returns an exact copy of this board. |
void |
domove(int c)
do the given move on this board. |
boolean |
finished()
returns true iff the game is finished. |
int |
get(int i)
get the value of the given field |
int |
get(int i,
int j)
get the value of the field indicated in 2dimensional coordinates. |
int |
getcoverage()
return the number of visible fields that are not free. |
int[] |
getevalvector(int[] out)
returns a certain set of number that will be used to evaluate the situation. |
int |
getflips(int c)
return the number of stones that would flip when playing c. |
int |
getplayer()
get the player currently moving: P1 or P2. |
boolean |
P1wins()
returns true if player 1 won the game. |
boolean |
P2wins()
returns true if player 2 won the game. |
void |
set(int i,
int value)
set the given field with the given value |
java.lang.String |
statusmessage()
returns a line of text describing the situation. |
void |
undomove()
undo the last move. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public int[] A
because A is onedimensional, you just need one integer to indicate a field. So instead of an object move all methods dealing with moves just use int's (note the huge speed improvement).
public static int OUT
public static int P1
public static int P2
public static int FREE
Constructor Detail |
public board()
Method Detail |
public board copy()
public int getplayer()
public void set(int i, int value)
public int get(int i)
public int get(int i, int j)
public void clear()
public void domove(int c)
public boolean canmove(int c)
public boolean finished()
public boolean P1wins()
public boolean P2wins()
public int getflips(int c)
public int getcoverage()
public int[] getevalvector(int[] out)
0 1 3 6 6 3 1 0 1 2 4 7 7 4 2 1 3 4 5 8 8 5 4 3 6 7 8 9 9 8 7 6 6 7 8 9 9 8 7 6 3 4 5 8 8 5 4 3 1 2 4 7 7 4 2 1 0 1 3 6 6 3 1 0But you should not care about how this table looks: What is important is that we value counters regarding their position, but using symmetries to limit the number of situations. the 11th number (that is out[10] or out[kinds]) return how many counters you are ahead (negative if behind) the twelth number return the number of moves you can do the last number tells you the number of counters you can flip in total.
If you add a certain feature that you think is important for winning chances, do it here and change evalvectorlength. The genetictrain and weightvectorclasses will automatically adjust if you recompile them. you must retrain before you use the applet, beacuse the standard weigth vector in the player class will then be too short.
out
- an optional array you want the result in (reusing memory improves the speed)
You can make it null if you do not have such array.public void undomove()
public java.lang.String statusmessage()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |