|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.htwdd.rosenkoenig.game.Player
de.htwdd.rosenkoenig.neuro.NeuroPlayer
public class NeuroPlayer
NeuroPlayer represents an artificial Rosenkoenig player that takes its decision based on the output of a neural network. To simulate GUI actions, the turn of a NeuroPlayer is executed in an independent thread.
| Nested Class Summary | |
|---|---|
private class |
NeuroPlayer.NeuroRunner
Used to (asynchrounusly) simulate GUI action. |
| Field Summary | |
|---|---|
private org.apache.log4j.Logger |
log
|
private NeuralNet |
net
The player's brain :-) |
private java.lang.Thread |
playerThread
Thread to simulate GUI actions. |
private static int |
TIME_TO_SLEEP
|
| Fields inherited from class de.htwdd.rosenkoenig.game.Player |
|---|
canMove, cards, game, hasMoved, highscore, knights, name, score |
| Constructor Summary | |
|---|---|
NeuroPlayer()
Creates a new NeuroPlayer with an uninitialized feed forward net. |
|
NeuroPlayer(java.lang.String playername)
Creates a new NeuroPlayer with an uninitialized feed forward net and the provided name. |
|
| Method Summary | |
|---|---|
org.jdom.Element |
createXml()
Creates an XML element containing this player's properties as well as its neural net. |
private void |
executeTurn()
Calculates and executes the next move based on the output of the player's neural net. |
protected void |
extractPlayer(org.jdom.Element xmlPlayer)
Extracts an artificial player from an XML element. |
NeuralNet |
getNet()
Getter of the property net |
boolean |
isInteractive()
If you derive from player and implement some kind of AI-player, return false here. |
void |
setNet(NeuralNet net)
Setter of the property net |
void |
turn()
Wakes up the player thread which executes the player's turn. |
| Methods inherited from class de.htwdd.rosenkoenig.game.Player |
|---|
equals, getCanMove, getCards, getGame, getHasMoved, getHighscore, getKnights, getName, getNumberOfCards, getScore, loadFromFile, saveToDir, setCanMove, setCards, setGame, setHasMoved, setHighscore, setKnights, setName, setScore, updateHighscore |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int TIME_TO_SLEEP
private org.apache.log4j.Logger log
private NeuralNet net
private java.lang.Thread playerThread
| Constructor Detail |
|---|
public NeuroPlayer()
public NeuroPlayer(java.lang.String playername)
playername - the player's name| Method Detail |
|---|
private void executeTurn()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic boolean isInteractive()
isInteractive in class Playerprotected void extractPlayer(org.jdom.Element xmlPlayer)
extractPlayer in class PlayerxmlPlayer - The xml portion of the player.
Implement this function, if you choose to save your player with several
properties to be loaded from an XML-filepublic org.jdom.Element createXml()
createXml in class Playerpublic void turn()
turn in class Playerpublic NeuralNet getNet()
public void setNet(NeuralNet net)
net - The net to set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||