org.xistrat.math
Class ChessEngine

java.lang.Object
  extended by java.lang.Thread
      extended by org.xistrat.math.ChessEngine
All Implemented Interfaces:
java.lang.Runnable, ClientUI

public class ChessEngine
extends java.lang.Thread
implements ClientUI, java.lang.Runnable

Engine provides an autoplayer engine for the XiStrat Chess variant

Since:
0.5.42

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int MOVE
           
static int NOTHING
           
static long sleepT
           
 int strength
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ChessEngine(F4ClientCore clientCore, boolean verbose, java.lang.String game, java.lang.String alias, int strength)
           
 
Method Summary
 void abort()
           
 void buildPlayField(java.lang.String positionID)
          later on make Engine and XiStratPanel extend s.th. and put that source code into 1 single place (or whatever design pattern (composition vs inheritance) might be used instead to avoid ugly copy/paste)
clientCore calls this after loginAck by server
does as well hashTables declaration and initialization
 void doMove(int from, int to)
          sync representation
 void doPass()
           
 void doPut(int to, int cont)
          dummy
 void doRemove(int loc, int cont)
          dummy
 void doUndo(int num)
           
 int evaluate(FigurData[] fastFigs, int atTurnOf)
          inside loop, we use an incremental procedure instead
 void handleNewGame(boolean ok, java.lang.String info)
          methods called by F4ClientCore, implemeting ClientUI
 void logout()
           
 void lose(java.lang.String winner)
           
 int[] multiEvaluate(FigurData[] fastFigs, int size)
           
 void run()
          for the moment we only do s.th. when it's our turn (no pondering, that is: no thinking on time of others so far)
 void setGameList(java.lang.String[] list, java.lang.String[] position)
          interface ClientUI
 void showErr(java.lang.String error)
           
 void showMsg(java.lang.String info)
           
 void waitForUserMove(boolean waitForMe)
           
 void waitForUserRemove(boolean wait)
           
 void waitForUserUndo(boolean undoForMe)
          after victory, engine is nice and makes undo of the last 2 elementar moves (plies)
 void win()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

strength

public final int strength

MOVE

public static final int MOVE
See Also:
Constant Field Values

NOTHING

public static final int NOTHING
See Also:
Constant Field Values

sleepT

public static final long sleepT
See Also:
Constant Field Values
Constructor Detail

ChessEngine

public ChessEngine(F4ClientCore clientCore,
                   boolean verbose,
                   java.lang.String game,
                   java.lang.String alias,
                   int strength)
Parameters:
strength - number of levels the search should do
Method Detail

run

public void run()
for the moment we only do s.th. when it's our turn (no pondering, that is: no thinking on time of others so far)

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

setGameList

public void setGameList(java.lang.String[] list,
                        java.lang.String[] position)
interface ClientUI

Specified by:
setGameList in interface ClientUI

handleNewGame

public void handleNewGame(boolean ok,
                          java.lang.String info)
methods called by F4ClientCore, implemeting ClientUI

Specified by:
handleNewGame in interface ClientUI

showMsg

public void showMsg(java.lang.String info)
Specified by:
showMsg in interface ClientUI

showErr

public void showErr(java.lang.String error)
Specified by:
showErr in interface ClientUI

abort

public void abort()
Specified by:
abort in interface ClientUI

logout

public void logout()
Specified by:
logout in interface ClientUI

lose

public void lose(java.lang.String winner)
Specified by:
lose in interface ClientUI

win

public void win()
Specified by:
win in interface ClientUI

waitForUserMove

public void waitForUserMove(boolean waitForMe)
Specified by:
waitForUserMove in interface ClientUI

waitForUserUndo

public void waitForUserUndo(boolean undoForMe)
after victory, engine is nice and makes undo of the last 2 elementar moves (plies)

Specified by:
waitForUserUndo in interface ClientUI

buildPlayField

public void buildPlayField(java.lang.String positionID)
later on make Engine and XiStratPanel extend s.th. and put that source code into 1 single place (or whatever design pattern (composition vs inheritance) might be used instead to avoid ugly copy/paste)


clientCore calls this after loginAck by server


does as well hashTables declaration and initialization

Specified by:
buildPlayField in interface ClientUI

doPut

public void doPut(int to,
                  int cont)
dummy

Specified by:
doPut in interface ClientUI

doRemove

public void doRemove(int loc,
                     int cont)
dummy

Specified by:
doRemove in interface ClientUI

doPass

public void doPass()
Specified by:
doPass in interface ClientUI

waitForUserRemove

public void waitForUserRemove(boolean wait)
Specified by:
waitForUserRemove in interface ClientUI

doMove

public void doMove(int from,
                   int to)
sync representation

Specified by:
doMove in interface ClientUI

doUndo

public void doUndo(int num)
Specified by:
doUndo in interface ClientUI

evaluate

public int evaluate(FigurData[] fastFigs,
                    int atTurnOf)
inside loop, we use an incremental procedure instead


multiEvaluate

public int[] multiEvaluate(FigurData[] fastFigs,
                           int size)