ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Winboard/Java help.
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Flat
View previous topic :: View next topic  
Author Message
Dan Honeycutt



Joined: 27 Feb 2006
Posts: 3242
Location: Atlanta, Georgia

PostPost subject: Winboard/Java help.    Posted: Sun Apr 22, 2012 4:52 pm Reply to topic Reply with quote

Hi all,

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:
java -jar moron.jar


Everything worked fine. Next I entered:

Code:
winboard.exe -cp -fcp "java -jar moron.jar" -scp "java -jar moron.jar" -debug


I got Startup failure on 'java -jar moron.jar': The System cannot find the file specified. I'm not sure who can't find what. I verified that there is a java.exe in my path. I'm probably missing something obvious but damned if I can see what it is.

The winboard debug file and a listing of my program are below. Any help would be greatly appreciated.

Thanks
Dan H.

Code:
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:
/*
 * 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");   
  }
}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Subject Author Date/Time
Winboard/Java help. Dan Honeycutt Sun Apr 22, 2012 4:52 pm
      Re: Winboard/Java help. Jim Ablett Sun Apr 22, 2012 6:07 pm
            Re: Winboard/Java help. Dan Honeycutt Sun Apr 22, 2012 9:04 pm
                  Re: Winboard/Java help. Jim Ablett Sun Apr 22, 2012 9:10 pm
                        Re: Winboard/Java help. Dan Honeycutt Sun Apr 22, 2012 9:41 pm
                              Re: Winboard/Java help. Sven Schüle Mon Apr 23, 2012 9:47 am
                                    Re: Winboard/Java help. Dan Honeycutt Mon Apr 23, 2012 3:17 pm
                                          Re: Winboard/Java help. Julien MARCEL Mon Apr 23, 2012 3:30 pm
                                                Re: Winboard/Java help. Dan Honeycutt Mon Apr 23, 2012 3:56 pm
                                                      Re: Winboard/Java help. Julien MARCEL Mon Apr 23, 2012 4:03 pm
                                                            Re: Winboard/Java help. Julien MARCEL Mon Apr 23, 2012 4:09 pm
                                                            Re: Winboard/Java help. Dan Honeycutt Mon Apr 23, 2012 4:29 pm
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads