Sunfish (Python Engine)

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Norbert Raimund Leisner
Posts: 1643
Joined: Tue May 20, 2008 4:57 pm
Location: Augsburg - Germany

Sunfish (Python Engine)

Post by Norbert Raimund Leisner »

Hello,

is Sunfish https://github.com/thomasahle/sunfish/ really a UCI-compatible engine? (CECP/WinBoard-protocol works of course)

Under Windows 7 SP1 32-bit and Python 3.6.4 https://www.python.org/downloads/windows/ including a batch-file python -u xboard.py the engine embedded into WinBoard-protocol runs normally, but not with UCI.

2018-01-02 14:26:58,164 Arena 3.5.1
2018-01-02 14:26:58,164Font Arena Chess Figurine MISSING

2018-01-02 14:26:58,257**----------New game---2018-01-02 14:26:58,257 Di -------------
2018-01-02 14:26:58,398**----------New game---2018-01-02 14:26:58,398 Di -------------
2018-01-02 14:26:58,476screen: 1280x1024
2018-01-02 14:26:58,476Monitors: 1
2018-01-02 14:26:58,476Monitor0: 1280x1024
2018-01-02 14:26:58,476FormMonitor: 0
2018-01-02 14:26:58,476**DesktopRect: 0/0 .. 1280/1024
2018-01-02 14:27:22,8141-------------------------Starting engine 1 Sunfish--------------------------
2018-01-02 14:27:22,8291Configured Engine 1 Type: Auto
2018-01-02 14:27:22,8291Engine 1 dir: C:\Users\NRL\Downloads\Python36
2018-01-02 14:27:22,8291Engine 1 commandline: C:\Users\NRL\Downloads\Python36\sunfish.bat
2018-01-02 14:27:22,9391Child Process Prio Adj: PID 340 python.exe
2018-01-02 14:27:22,9391Engine 1 ProcessID: 3400
2018-01-02 14:27:22,9391Engine 1 Prio:32 ThreadPrio:0
2018-01-02 14:27:22,939-->1:xboard
2018-01-02 14:27:22,970<--1:C:\Users\NRL\Downloads\Python36>python -u xboard.py
2018-01-02 14:27:22,970-->1:uci
2018-01-02 14:27:22,970<--1:Error (unkown command): uci
2018-01-02 14:27:31,331-->1:isready
2018-01-02 14:27:31,378<--1:Error (unkown command): isready
2018-01-02 14:27:32,127-->1:new
2018-01-02 14:27:32,127-->1:random
2018-01-02 14:27:32,127-->1:level 0 5 0
2018-01-02 14:27:32,127-->1:post
2018-01-02 14:27:32,127-->1:hard
2018-01-02 14:27:32,127-->1:easy
2018-01-02 14:27:32,158<--1:Error (unkown command): easy
2018-01-02 14:27:39,701-->1:?
2018-01-02 14:27:39,701-->1:force
2018-01-02 14:27:39,701-->1:quit
2018-01-02 14:27:40,2011-------------------------Starting engine 1 Sunfish--------------------------
2018-01-02 14:27:40,2011Configured Engine 1 Type: UCI
2018-01-02 14:27:40,2011Engine 1 dir: C:\Users\NRL\Downloads\Python36
2018-01-02 14:27:40,2011Engine 1 commandline: C:\Users\NRL\Downloads\Python36\sunfish.bat
2018-01-02 14:27:40,3101Child Process Prio Adj: PID 896 python.exe
2018-01-02 14:27:40,3101Engine 1 ProcessID: 3252
2018-01-02 14:27:40,3101Engine 1 Prio:32 ThreadPrio:0
2018-01-02 14:27:40,341<--1:C:\Users\NRL\Downloads\Python36>python -u xboard.py
2018-01-02 14:27:40,341-->1:uci
2018-01-02 14:27:40,341<--1:Error (unkown command): uci
2018-01-02 14:27:48,344-->1:isready
2018-01-02 14:27:48,391<--1:Error (unkown command): isready
2018-01-02 14:27:52,478-->1:quit
2018-01-02 14:27:52,9771-------------------------Starting engine 1 Sunfish--------------------------
2018-01-02 14:27:52,9771Configured Engine 1 Type: UCI
2018-01-02 14:27:52,9771Engine 1 dir: C:\Users\NRL\Downloads\Python36
2018-01-02 14:27:52,9771Engine 1 commandline: C:\Users\NRL\Downloads\Python36\sunfish.bat
2018-01-02 14:27:53,0861Child Process Prio Adj: PID 2604 python.exe
2018-01-02 14:27:53,0861Engine 1 ProcessID: 3040
2018-01-02 14:27:53,0861Engine 1 Prio:32 ThreadPrio:0
2018-01-02 14:27:53,117<--1:C:\Users\NRL\Downloads\Python36>python -u xboard.py
2018-01-02 14:27:53,117-->1:uci
2018-01-02 14:27:53,117<--1:Error (unkown command): uci
2018-01-02 14:28:01,120-->1:isready
2018-01-02 14:28:01,167<--1:Error (unkown command): isready
2018-01-02 14:28:43,7661Start calc, move no: 1
2018-01-02 14:28:43,766-->1:ucinewgame
2018-01-02 14:28:43,766-->1:isready
2018-01-02 14:28:43,766<--1:Error (unkown command): ucinewgame
2018-01-02 14:28:43,766<--1:Error (unkown command): isready
2018-01-02 14:28:43,875-->1:position startpos moves e2e4
2018-01-02 14:28:43,875-->1:go wtime 300000 btime 300000 winc 0 binc 0
2018-01-02 14:28:43,875<--1:Error (unkown command): position startpos moves e2e4
2018-01-02 14:28:43,875<--1:Error (unkown command): go wtime 300000 btime 300000 winc 0 binc 0
2018-01-02 14:33:45,382-->1:stop
2018-01-02 14:33:45,429<--1:Error (unkown command): stop

same procedure, but with batch-file python -u uci.py
2018-01-02 15:22:50,838 Arena 3.5.1
2018-01-02 15:22:50,853Font Arena Chess Figurine MISSING

2018-01-02 15:22:51,274**----------Neue Partie---2018-01-02 15:22:51,274 Di -------------
2018-01-02 15:22:51,368screen: 1280x1024
2018-01-02 15:22:51,368Monitors: 1
2018-01-02 15:22:51,368Monitor0: 1280x1024
2018-01-02 15:22:51,368FormMonitor: 0
2018-01-02 15:22:51,368DesktopRect: 0/0 .. 1280/1024
2018-01-02 15:22:51,446Lade 1
2018-01-02 15:23:21,1841---------------------------Starte Motor 1 Sunfish---------------------------
2018-01-02 15:23:21,1841Configured Engine 1 Type: Auto
2018-01-02 15:23:21,1841Engine 1 dir: C:\Users\NRL\Downloads\Python36
2018-01-02 15:23:21,1841Engine 1 commandline: C:\Users\NRL\Downloads\Python36\sunfish.bat
2018-01-02 15:23:21,3081Engine 1 ProcessID: 3408
2018-01-02 15:23:21,3081Engine 1 Prio:32 ThreadPrio:0
2018-01-02 15:23:21,308-->1:xboard
2018-01-02 15:23:21,340-->1:uci
2018-01-02 15:23:21,418<--1:C:\Users\NRL\Downloads\Python36>python -u uci.py
2018-01-02 15:23:22,510<--1:Traceback (most recent call last):
2018-01-02 15:23:22,510<--1: File "uci.py", line 15, in
2018-01-02 15:23:22,510<--1: from xboard import Unbuffered, sunfish, input
2018-01-02 15:23:22,510<--1:ImportError: cannot import name 'input'
2018-01-02 15:23:29,342-->1:isready
2018-01-02 15:23:29,514-->1:?
2018-01-02 15:23:29,514-->1:force
2018-01-02 15:23:29,514-->1:quit
2018-01-02 15:23:30,0131---------------------------Starte Motor 1 Sunfish---------------------------
2018-01-02 15:23:30,0131Configured Engine 1 Type: UCI
2018-01-02 15:23:30,0131Engine 1 dir: C:\Users\NRL\Downloads\Python36
2018-01-02 15:23:30,0131Engine 1 commandline: C:\Users\NRL\Downloads\Python36\sunfish.bat
2018-01-02 15:23:30,1221Engine 1 ProcessID: 3480
2018-01-02 15:23:30,1221Engine 1 Prio:32 ThreadPrio:0
2018-01-02 15:23:30,122<--1:C:\Users\NRL\Downloads\Python36>python -u uci.py
2018-01-02 15:23:30,154<--1:Traceback (most recent call last):
2018-01-02 15:23:30,154-->1:uci
2018-01-02 15:23:30,154<--1: File "uci.py", line 15, in
2018-01-02 15:23:30,154<--1: from xboard import Unbuffered, sunfish, input
2018-01-02 15:23:30,154<--1:ImportError: cannot import name 'input'
2018-01-02 15:23:38,156-->1:isready
2018-01-02 15:23:39,248-->1:quit
2018-01-02 15:23:39,7481---------------------------Starte Motor 1 Sunfish---------------------------
2018-01-02 15:23:39,7481Configured Engine 1 Type: UCI
2018-01-02 15:23:39,7481Engine 1 dir: C:\Users\NRL\Downloads\Python36
2018-01-02 15:23:39,7481Engine 1 commandline: C:\Users\NRL\Downloads\Python36\sunfish.bat
2018-01-02 15:23:39,8571Engine 1 ProcessID: 3528
2018-01-02 15:23:39,8571Engine 1 Prio:32 ThreadPrio:0
2018-01-02 15:23:39,888<--1:C:\Users\NRL\Downloads\Python36>python -u uci.py
2018-01-02 15:23:39,888-->1:uci
2018-01-02 15:23:39,888<--1:Traceback (most recent call last):
2018-01-02 15:23:39,888<--1: File "uci.py", line 15, in
2018-01-02 15:23:39,888<--1: from xboard import Unbuffered, sunfish, input
2018-01-02 15:23:39,888<--1:ImportError: cannot import name 'input'
2018-01-02 15:23:47,891-->1:isready

Best wishes,
Norbert
thomasahle
Posts: 94
Joined: Thu Feb 27, 2014 8:19 pm

Re: Sunfish (Python Engine)

Post by thomasahle »

Hi Norbert,
I didn't write the UCI component myself, but I think it used to work. Maybe later changes to sunfish broke it.
If you make any fixed, I'll be happy to include them!

Best, Thomas
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Sunfish (Python Engine)

Post by Evert »

The log indicates that Arena switches the engine to CECP mode (by sending "xboard") before trying to switch it to UCI mode (by sending "uci"). This could be the source of the problem, if the engine is not designed to freely switch between the two modes (which is not necessary normally).
At any rate, the engine response ("Error (unknown command): uci") is technically correct: "uci" is not a valid CECP command.

Is it possible to prevent Arena from trying CECP first?
tmokonen
Posts: 1296
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: Sunfish (Python Engine)

Post by tmokonen »

Evert wrote:The log indicates that Arena switches the engine to CECP mode (by sending "xboard") before trying to switch it to UCI mode (by sending "uci"). This could be the source of the problem, if the engine is not designed to freely switch between the two modes (which is not necessary normally).
At any rate, the engine response ("Error (unknown command): uci") is technically correct: "uci" is not a valid CECP command.

Is it possible to prevent Arena from trying CECP first?
Arena sent both Winboard and UCI commands because the engine was configured with the Type option set to Autodetect, as shown in this line in the log file:

2018-01-02 14:27:22,8291Configured Engine 1 Type: Auto

If the Type is set to Winboard or Winboard (old), Arena will only send CECP commands (no protover support if Winboard (old)), and if the Type is set to UCI, Arena will only send UCI commands.