I've been trying to learn some Java programming. I thought a good exercise would be to write a simple engine. I started with a really simple one just to see if I could 'talk' to winboard. All the program does is get two winboard commands and send a message back. I built my .jar file and copied it to my winboard directory. I then opened a cmd prompt, navigated to the winboard folder and ran my program with:
Code: Select all
java -jar moron.jar
Code: Select all
winboard.exe -cp -fcp "java -jar moron.jar" -scp "java -jar moron.jar" -debug
The winboard debug file and a listing of my program are below. Any help would be greatly appreciated.
Thanks
Dan H.
Code: Select all
WinBoard 4.4.0 + java
Reset(1, 0) from gameMode 0
recognized 'normal' (-1) as variant normal
GameEnds(0, (null), 2)
shuffleOpenings = 0
TC string = '+5+30'
mps=0 tc=300000 inc=30000
TC string = '+5+30'
mps=0 tc=300000 inc=30000
StartChildProcess (dir="") java -jar moron.jar
Fatal Error: Startup failure on 'java -jar moron.jar':
The system cannot find the file specified.
GameEnds(40, xboard exit, 2)
Code: Select all
/*
* Java translation of the famous Moron engine by Fernando Villegas
*/
package moron;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Scanner;
public class Moron {
static String fromWinboard() { //get winboard command
Scanner scan = new Scanner(System.in);
String cmd = scan.nextLine();
writeLog("<- " + cmd); //record what we got
return cmd;
}
static void toWinboard(String msg) { //send message to winboard
System.out.println(msg);
System.out.flush();
writeLog("-> " + msg);
}
static void writeLog(String msg) {
String eol = System.getProperty("line.separator");
try (BufferedWriter out = new BufferedWriter(new FileWriter("log.txt", true))) {
out.write(msg + eol);
out.close(); //Close the output stream
} catch (Exception e) { //Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
public static void main(String[] args) {
fromWinboard(); //xboard
fromWinboard(); //protover 2
toWinboard("feature done=0 myname=Moron done=1");
}
}