Page 1 of 1

A strange behaviour by Mediocre (Java/Linux problem?)

PostPosted: 19 Mar 2008, 12:55
by Volker Pittlik
While installing the newest versions of the engines on my computer I re-discovered a strange behaviour by Mediocre. I found a way to avoid the problem, but I don't understand how the solution works ;-). Maybe a java or linux expert can explain this.

Background for winboard users: there is nothing similar to a winboard.ini in linux. One possibility to start xboard matching two engines would be to type somthing similar as
Code: Select all
nice xboard -tc $tc -inc $inc -mps $mps -xexit -$debugType -$ponderType -fcp "$fcp" -fd $fd -scp "$scp" -sd $sd -size $size -highlight -drag -legal -timeDelay -1 -coords -$autoflagType -xreuse -xreuse2 -sgf $sgf -$thinkingType -mg $mg


Of course I'm much to lazy for that. Therefore I start xboard using two scripts (something similar as a .bat file, but much more powerful). One script informs xboard about the time control, design of the board and so on, the other is engine specific and informs xboard about the name of the engine and the path to it.

For a usual executale xboard engine this script looks like this one:

Code: Select all
#! /bin/bash

fcp=./crafty220
fd=$cp/crafty


Those who are familar with winboard weill easily guess what it does.

Because Mediocre is a java engine there is no executable which can run by itself. It has to be started using java with some additional options. It seems to be correct to put all that in the script:

Code: Select all
#! /bin/bash

fcp="java -Xmx1024M -classpath /home/volker/schach/mediocre/mediocre_v0.332/bin Mediocre"
fd=$cp/mediocre/mediocre_v0.332/bin


Unfortunately that does not work, but ends in a crash:

Code: Select all
volker@vpittlik:~/schach> xbtest

...
xboard 4.2.7 + java
...
StartChildProcess (dir="/home/volker/schach/mediocre/mediocre_v0.332/bin") java -Xmx1024M -classpath /home/volker/schach/mediocre/mediocre_v0.332/bin Mediocre
76 >first : xboard
protover 2
400 <first :
400 <first : Welcome to Mediocre v0.332. Type 'help' for commands.
...
734 >first : go
748 <first : move g1f3
...
1083 >first : usermove 1083 >first : b7b6
AnimateMove: piece 6 slides from 1,6 to 1,5
xboard: Error: first chess program (java -Xmx1024M -classpath /home/volker/schach/mediocre/mediocre_v0.332/bin Mediocre) exited unexpectedly


Now my walk around which I don't understand myself:

If i use the first line of the script in a script of its own then the program works fine! the additional script contains the first line only.
Code: Select all
#! /bin/bash

java -Xmx1024M -classpath /home/volker/schach/mediocre/mediocre_v0.332/bin Mediocre

and in the initial script fcp is replaced by the name of that additional script. Maybe this is useful for someone else or someone can explain me why this works.


Volker

Re: A strange behaviour by Mediocre (Java/Linux problem?)

PostPosted: 18 Apr 2008, 15:51
by Casper W. Berg
I have had problems with Mediocre and other Java engines with xboard too. They crash when xboard sends interrupts.

I fixed it by adding "sigint=0" and "sigterm=0" to the list of features that the engine sends to xboard.

That is, in Mediocre.java, change

Code: Select all
...
   private static void winBoard() throws IOException
   {
      Board board = new Board(); // Create a board on which we will be playing
      board.setupStart(); // Start position
      System.out.println("");
      System.out.println("feature myname=\"Mediocre " + VERSION + "\" usermove=1 setboard=1 colors=0 analyze=0 done=1");
...


to

Code: Select all
   private static void winBoard() throws IOException
   {
      Board board = new Board(); // Create a board on which we will be playing
      board.setupStart(); // Start position
      System.out.println("");
      System.out.println("feature myname=\"Mediocre " + VERSION + "\" usermove=1 setboard=1 colors=0 analyze=0 " +
                "sigint=0 sigterm=0 done=1");

Re: A strange behaviour by Mediocre (Java/Linux problem?)

PostPosted: 19 Apr 2008, 11:01
by Volker Pittlik
Casper W. Berg wrote:... They crash when xboard sends interrupts.

I fixed it by adding "sigint=0" and "sigterm=0" to the list of features that the engine sends to xboard.

...


Sounds logical because sigint and sigterm are "1" by default. I'll try that in the furture. Right now my workaround works well too.

Volker