de.htwdd.rosenkoenig.neuro
Class NeuroPlayer

java.lang.Object
  extended by de.htwdd.rosenkoenig.game.Player
      extended by de.htwdd.rosenkoenig.neuro.NeuroPlayer

public class NeuroPlayer
extends Player

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

TIME_TO_SLEEP

private static final int TIME_TO_SLEEP
See Also:
Constant Field Values

log

private org.apache.log4j.Logger log

net

private NeuralNet net
The player's brain :-)


playerThread

private java.lang.Thread playerThread
Thread to simulate GUI actions.

Constructor Detail

NeuroPlayer

public NeuroPlayer()
Creates a new NeuroPlayer with an uninitialized feed forward net.


NeuroPlayer

public NeuroPlayer(java.lang.String playername)
Creates a new NeuroPlayer with an uninitialized feed forward net and the provided name.

Parameters:
playername - the player's name
Method Detail

executeTurn

private void executeTurn()
                  throws java.lang.InterruptedException
Calculates and executes the next move based on the output of the player's neural net.

Throws:
java.lang.InterruptedException

isInteractive

public boolean isInteractive()
If you derive from player and implement some kind of AI-player, return false here.

Specified by:
isInteractive in class Player
Returns:
false if some kind of AI-player, true otherwise.

extractPlayer

protected void extractPlayer(org.jdom.Element xmlPlayer)
Extracts an artificial player from an XML element.

Specified by:
extractPlayer in class Player
Parameters:
xmlPlayer - 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-file

createXml

public org.jdom.Element createXml()
Creates an XML element containing this player's properties as well as its neural net.

Specified by:
createXml in class Player
Returns:
an xml element that you want this class to save for you. Implement this function, if you choose to save your player with several properties to be saved in an XML-file.

turn

public void turn()
Wakes up the player thread which executes the player's turn.

Specified by:
turn in class Player

getNet

public NeuralNet getNet()
Getter of the property net

Returns:
Returns the net.

setNet

public void setNet(NeuralNet net)
Setter of the property net

Parameters:
net - The net to set.