Class player
java.lang.Object
|
+--player
- All Implemented Interfaces:
- java.lang.Runnable
- public class player
- extends java.lang.Object
- implements java.lang.Runnable
this class is a computer player, that calculates what move to do
in a given situation.
|
Field Summary |
java.lang.String |
W
The string W is the evaluation string used to evaluate situations. |
|
Constructor Summary |
player(board ib,
int iside)
create a player. |
player(board ib,
int iside,
boardview ibv)
create a player for applet mode: the player calculates in a separate thread,
and wait 4 seconds before answering. |
|
Method Summary |
void |
ask(java.lang.String s)
the method you can call if you want this player to think of a move in a
separate thread. |
int |
bestmove()
this functions returns the move that this player thinks is best. |
void |
run()
the method that will run in a separate thread. |
void |
setstrength(int l)
determines how far the computer looks ahead, higher value plays
better, but takes more time. |
void |
setweight(int[] w)
set the weight vector this player should use. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
W
public java.lang.String W
- The string W is the evaluation string used to evaluate situations. It was
calculate with the genetictrain class, and then inserted in this sourcecode.
player
public player(board ib,
int iside)
- create a player.
- Parameters:
ib - the board that is used.iside - the side the player takes: board.P1 or board.P2
player
public player(board ib,
int iside,
boardview ibv)
- create a player for applet mode: the player calculates in a separate thread,
and wait 4 seconds before answering.
- Parameters:
ib - the board that is used.iside - the side the player takes: board.P1 or board.P2ibv - the boardview it must answer to.
setstrength
public void setstrength(int l)
- determines how far the computer looks ahead, higher value plays
better, but takes more time. I think even values are better, because
that gives the opponent the last move, but that is personal.
setweight
public void setweight(int[] w)
- set the weight vector this player should use.
ask
public void ask(java.lang.String s)
- the method you can call if you want this player to think of a move in a
separate thread. This function returns immediately, so the caller can do something
different. The answers will be given after 4 seconds or longer to the
boardview by the method answer.
- Parameters:
s - a string that is not used. It can be used for comment by a caller. Do
not take it too seriously: it is an inside joke to include comment in extra parameters.
run
public void run()
- the method that will run in a separate thread. Do not call this function yourself,
but use ask.
- Specified by:
run in interface java.lang.Runnable
bestmove
public int bestmove()
- this functions returns the move that this player thinks is best. Use this function
if you just want the best move, no extra threads and no delays.
- Returns:
- a move