93 lines
1.9 KiB
Java
93 lines
1.9 KiB
Java
package dev.kske.chess.game;
|
|
|
|
import java.io.IOException;
|
|
|
|
import dev.kske.chess.board.Move;
|
|
import dev.kske.chess.board.Piece.Color;
|
|
import dev.kske.chess.uci.UCIHandle;
|
|
import dev.kske.chess.uci.UCIListener;
|
|
|
|
/**
|
|
* Project: <strong>Chess</strong><br>
|
|
* File: <strong>UCIPlayer.java</strong><br>
|
|
* Created: <strong>18.07.2019</strong><br>
|
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
|
*/
|
|
public class UCIPlayer extends Player implements UCIListener {
|
|
|
|
private UCIHandle handle;
|
|
|
|
public UCIPlayer(Color color, String enginePath) {
|
|
super(color);
|
|
try {
|
|
handle = new UCIHandle(enginePath);
|
|
handle.setListener(this);
|
|
handle.start();
|
|
} catch (IOException ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void requestMove() {
|
|
handle.positionFEN(board.toFEN());
|
|
handle.go();
|
|
}
|
|
|
|
@Override
|
|
public void cancelMove() {
|
|
handle.stop();
|
|
}
|
|
|
|
@Override
|
|
public void disconnect() {
|
|
handle.quit();
|
|
}
|
|
|
|
@Override
|
|
public void onIdName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
@Override
|
|
public void onBestMove(String move) {
|
|
Move moveObj = Move.fromSAN(move);
|
|
game.onMove(this, moveObj);
|
|
}
|
|
|
|
@Override
|
|
public void onBestMove(String move, Move ponderMove) {
|
|
onBestMove(move);
|
|
}
|
|
|
|
@Override
|
|
public void onCopyProtectionChecking() {
|
|
System.out.println("Copy protection checking...");
|
|
}
|
|
|
|
@Override
|
|
public void onCopyProtectionOk() {
|
|
System.out.println("Copy protection ok");
|
|
}
|
|
|
|
@Override
|
|
public void onCopyProtectionError() {
|
|
System.err.println("Copy protection error!");
|
|
}
|
|
|
|
@Override
|
|
public void onRegistrationChecking() {
|
|
System.out.println("Registration checking...");
|
|
}
|
|
|
|
@Override
|
|
public void onRegistrationOk() {
|
|
System.out.println("Registration ok");
|
|
}
|
|
|
|
@Override
|
|
public void onRegistrationError() {
|
|
System.err.println("Registration error!");
|
|
}
|
|
}
|