Scan

Discussion about development of draughts in the time of computer and Internet.
Post Reply
BertTuyt
Posts: 1592
Joined: Wed Sep 01, 2004 19:42

Re: Scan

Post by BertTuyt » Sat Sep 19, 2015 23:04

Fabien, I encountered a strange problem, hope you have a clue.

The Pipes seem to work now, and I can communicate with Scan.
The first moves in a game are no problem, when I enter a move (with the mouse on my GUI), Scan enters with a book move.
Things go wrong, when Scan starts thinking and sends the move.
The move is normally processed by the Damage GUI.
However on the move I hereafter sent to Scan, I get a Illegal Move Error reply.
From what I can see there seems nothing wrong with the move format send.
And it always occur after the first search of Scan, so when its out of opening book.

Hope this sounds familiar...

Another small thing, I have to sent the init command initially.
Is there a reason that Scan does not execute the init self at start-up and then sends the name and author?

So far (at least with the aforementioned "bug" in mind), I implemented the next San commands already in the Damage GUI:
depth, go, level, move, new, stop.

So I hope soon most will work.


Bert

Fabien Letouzey
Posts: 299
Joined: Tue Jul 07, 2015 07:48
Real name: Fabien Letouzey

Re: Scan

Post by Fabien Letouzey » Sun Sep 20, 2015 09:00

BertTuyt wrote:The Pipes seem to work now, and I can communicate with Scan.
The first moves in a game are no problem, when I enter a move (with the mouse on my GUI), Scan enters with a book move.
Things go wrong, when Scan starts thinking and sends the move.
The move is normally processed by the Damage GUI.
However on the move I hereafter sent to Scan, I get a Illegal Move Error reply.
From what I can see there seems nothing wrong with the move format send.
And it always occur after the first search of Scan, so when its out of opening book.

Hope this sounds familiar...
No, but I'm used to eternal confusion around protocol categories. In the first post in the "Protocols and tools" thread, I compared event-based protocols where you send events (mostly moves) that occurred during a time interval, to position-based protocols where you send the relevant part of the state before every search (position + clock information). It's connected to functional programming: engine_move = search(pos, time); so you need to send the position and time information just like for function calls (except that it's in text form).

I suspect that you tried sending events (in your case, user moves) instead of the current position every time that Scan is expecting. It only accidentally worked for book moves because Scan updates its board when looking for a move to ponder on (which the book doesn't provide on its own).

Here's an actual (but edited) log-file extract from the Olympiad (">" = to engine, "<" = from engine):
---
> pos wbbbbbbbbbbbbbbbbbbbbeeeeeeeeeewwwwwwwwwwwwwwwwwwww
> level 75 1320000 0
> go
< info 0 0.0 0 0 0.00 0.0 34-30
< move 34-30 17-21
> pos wbbbbbbbbbbbbbbbbbbebeebeeeeeewwwwewwwwwwwwwwwwwwww
> level 74 1319997 0
> go
< info 0 0.0 0 0 0.00 0.0 30-25
< move 30-25 20-24
> pos wbbbbbbbbbbbbbbbbbbeeeebbweeeeewwwewwwwwwwwwwwwwwww
> level 73 1319993 0
> ponder
< info 0 0.0 0 0 0.00 0.0 33-29
< move 33-29 23x34x29
...
---
Another small thing, I have to sent the init command initially.
Is there a reason that Scan does not execute the init self at start-up and then sends the name and author?
There are three. 1) the GUI needs to know quickly whether the engine supports the protocol (timeout). 2) initialisation depends on GUI parameters so the engine has to give the GUI a chance to set them first. Setting "bb-size" to 5 will make loading much faster for instance. 3) I wanted to respect a concept in the UCI documentation, even though I have no use for it yet:

---
* The engine should boot and wait for input from the GUI,
the engine should wait for the "isready" or "setoption" command to set up its internal parameters
as the boot process should be as quick as possible.
---

We can imagine a GUI just wanting to collect the engine name or parameters.

Unrelated to your questions, UCI is using "isready" for two purposes: initialisation and synchronisation; I separated it into "init" and "ping".
Last edited by Fabien Letouzey on Sun Sep 20, 2015 09:11, edited 1 time in total.

Fabien Letouzey
Posts: 299
Joined: Tue Jul 07, 2015 07:48
Real name: Fabien Letouzey

Re: Scan

Post by Fabien Letouzey » Sun Sep 20, 2015 09:08

Fabien Letouzey wrote:Here's an actual (but edited) log-file extract from the Olympiad (">" = to engine, "<" = from engine):
...
I should add a more complicated example with reversible (king) moves, for the purpose of repetition detection:

> pos beeeWWeeeeeeeeeeeeeeeeeeeweeeeeeeeewweBeeeeeeeeeBee
> move 38-15
> move 5-41
> move 48-26
> level 9 291587 0
> ponder

You can also send all moves from the starting position. This is what most UCI engines would be expecting.

Krzysztof Grzelak
Posts: 1368
Joined: Thu Jun 20, 2013 17:16
Real name: Krzysztof Grzelak

Re: Scan

Post by Krzysztof Grzelak » Sun Sep 20, 2015 12:06

I have a question Fabien. During the Olympics which version of linux you used so that you can start Scan.

BertTuyt
Posts: 1592
Joined: Wed Sep 01, 2004 19:42

Re: Scan

Post by BertTuyt » Sun Sep 20, 2015 15:23

Fabien, thanks, it all works.

I now need to think about the handshake process you mentioned in the beginning, so I don't need to input init myself.
Next to that I need to modify several GUI commands, like take back move, to deal with the dual protocol implementation.
I didn't need to modify Scan for this purpose.
See some screenshots below

Bert
Attachments
Damage ScanPNG.PNG
Damage ScanPNG.PNG (705.65 KiB) Viewed 15675 times
Affter Init.PNG
Affter Init.PNG (12.8 KiB) Viewed 15675 times
Init.PNG
Init.PNG (23.3 KiB) Viewed 15675 times

Fabien Letouzey
Posts: 299
Joined: Tue Jul 07, 2015 07:48
Real name: Fabien Letouzey

Re: Scan

Post by Fabien Letouzey » Sun Sep 20, 2015 16:32

Krzysztof Grzelak wrote:I have a question Fabien. During the Olympics which version of linux you used so that you can start Scan.
It was my friend's computer (Jirong Lin, who was operating various programs for the whole week). I think it was Ubuntu; I'll let you know in the case I'm wrong.

Fabien Letouzey
Posts: 299
Joined: Tue Jul 07, 2015 07:48
Real name: Fabien Letouzey

Re: Scan

Post by Fabien Letouzey » Sun Sep 20, 2015 16:37

BertTuyt wrote:Fabien, thanks, it all works.
I'm glad to hear it. Problems like this are usually solved quickly by sending a log file to the engine author. Just make sure to include both sides of the communication.
I now need to think about the handshake process you mentioned in the beginning, so I don't need to input init myself.
Contrary to game playing (especially with pondering), starting the engine follows a fixed pattern:

> hub
> set <var> <val> (optional)
> set <var> <val> (optional)
> ...
> init
< init eval (cosmetic-only, ignore unknown commands from the engine)
< ready
Next to that I need to modify several GUI commands, like take back move, to deal with the dual protocol implementation.
I didn't need to modify Scan for this purpose.
Yes; it's somewhat tricky because most programmers seem to focus too much on the events and want to transmit something immediately. On the GUI side, what I do is only update the GUI state; remember that the engine doesn't receive any events, only commands. When the GUI determines that it's the engine's turn to play (or ponder), I send the position + time information (from the GUI state) as usual. For disruptive events like new game/position, undo, or ponder miss, I just send "stop" to the engine; it's harmless if the engine wasn't thinking (but the GUI needs to remember to ignore the resulting engine move).

Ed Gilbert
Posts: 859
Joined: Sat Apr 28, 2007 14:53
Real name: Ed Gilbert
Location: Morristown, NJ USA
Contact:

Re: Scan

Post by Ed Gilbert » Thu Oct 01, 2015 18:23

I made a couple of changes to scan to enhance its capabilities in DXP matches:

- When I tried to run multiple simultaneous DXP matches between scan and kingsrow on an 8-core server, I ran into a problem. When scan acts as a DXP server, it leaves the listening socket open after it accepts a connection from a remote host. This ties up the DXP port so that it cannot be used by another pair of opponents. I modified socket.cpp to close the socket that listens for new connections after it accepts a connection.

- In order to run automated matches at fast time controls, it is necessary to send a value in the Time field of the DXP GAMEREQ message that is a fraction of a minute. The message format allows 3 characters for the Time value, so for example "0.1" can be sent. I modified the file dxp.cpp to accept Time in floating point format.

The modified files are attached here. With these changes I can run 8 simultaneous matches of 12-second games on the server.

-- Ed
Attachments
scan_changes.zip
(5.77 KiB) Downloaded 583 times

BertTuyt
Posts: 1592
Joined: Wed Sep 01, 2004 19:42

Re: Scan

Post by BertTuyt » Thu Oct 01, 2015 20:46

Ed, thanks for sharing.
Any interesting results worth mentioning.

Bert

BertTuyt
Posts: 1592
Joined: Wed Sep 01, 2004 19:42

Re: Scan

Post by BertTuyt » Mon Oct 19, 2015 20:47

Fabien, after several weeks again some time for programming.
After some reading I also basically like the UCI protocol.
As I now have implemented pipes (so redirect stdin and stdout), I can work on a better implementation of UDI (so Draughts in stead of Chess).
If you want to name it the HUB protocol, it is also good for me.

So the first command the GUI now sends is hub, and Scan responds by Scan 2.0 by Fabien Letouzey.

If we go for a UDI (or HUB) implementation, Scan should respond with:
id name Scan 2.0
id author Fabien Letouzey

Than the GUI could send an init command, and after a while the program sends a readyok (but ready is also ok for me).

If we agree on this part, I can implement at least this start sequence, and test if it works with a modified scan 2.0 (or maybe you want to issue the modification).

Also on the other parts all should agree.
So far I need to input the init myself, but for the rest I'm able to play a game against Scan 2.0

And it evident, that the modified Damage GUI will become available for all, and for free.

Bert

Fabien Letouzey
Posts: 299
Joined: Tue Jul 07, 2015 07:48
Real name: Fabien Letouzey

Re: Scan

Post by Fabien Letouzey » Tue Oct 20, 2015 17:56

BertTuyt wrote:If we agree on this part, I can implement at least this start sequence, and test if it works with a modified scan 2.0 (or maybe you want to issue the modification).
I'm not sure what you're proposing: full UDI or only the initialisation part? And if the latter, why?

Sure I can implement UDI, no problem. But you need to specify everything that's different from chess: at least FEN and moves. Also I won't be able to test anything, so it's going to be a draft.

BertTuyt
Posts: 1592
Joined: Wed Sep 01, 2004 19:42

Re: Scan

Post by BertTuyt » Tue Oct 20, 2015 19:25

Fabien, for now only the initialization part.
I will go through the UCI document, and compile a UDI variant.

Maybe we can start with a minimal implementation.
So its sufficient for standard games, and maybe tournaments.

I want to figure out how to attach 2 engines via pipes to the Damage GUI,
so in the future UDI enabled engines can play tournaments in an easy way.

Bert

BertTuyt
Posts: 1592
Joined: Wed Sep 01, 2004 19:42

Re: Scan

Post by BertTuyt » Sat Oct 24, 2015 17:47

I have slightly modified Scan (will provide the few things I have done in a separate post) and modified Damage accordingly.

See next link: https://www.dropbox.com/sh/u1nekyp94kjz ... bZbka?dl=0

Not 100% sure if it all works, as I compiled both with the (new) Visual Studio 2015 Community Edition, so I might need to add some Microsoft stuff.

To see all UDI Messages (including the info output) from Scan, rightclick in the Engine View window, and select Settings.
In Settings checkmark Display GUIDE Messages.

I used a very basic implementation of UDI.
The only things that work:
- Before starting a game, set time settings with Levels Normal Game.
- Than on can select Player- Engine or Engine - Player.
- With new one can start a new game

As I didn't test all in detail, there might be bugs, so hope to hear, so I can improve.
I will continue to add more Damage GUI functionality.

But at least I hope the Damage GUI adds value for some people.

Bert
Last edited by BertTuyt on Sat Oct 24, 2015 19:04, edited 2 times in total.

BertTuyt
Posts: 1592
Joined: Wed Sep 01, 2004 19:42

Re: Scan

Post by BertTuyt » Sat Oct 24, 2015 17:58

The small changes in Scan 2.0

At start of main() I disabled the Scan output string.

Code: Select all

 //  std::cout << "Scan 2.0 by Fabien Letouzey" << std::endl; bthack
The start command for Scan is hub (maybe a better name would be UDI)
and Hub processing is also slightly changed.

Code: Select all

 } else if (arg == "hub") {

      // bthack
	  std::cout << "id name Scan 2.0" << std::endl;
	  std::cout << "id author Fabien Letouzey" << std::endl;
	  std::cout << "ready" << std::endl;

      listen_input();
      hub_loop();

   } else {
In principle these were the only changes.
Although in UCI the info output is detailed, for now a freeform output is OK(ish).

The first ready in the Damage GUI triggers the init command, and after the second ready the Engine is activated.
So far no timeout or complex processing in case a second ready is not (or too late) communicated.

See the initial Scan Output.

Bert
Attachments
Scan Output.PNG
Scan Output.PNG (22.98 KiB) Viewed 15096 times

Krzysztof Grzelak
Posts: 1368
Joined: Thu Jun 20, 2013 17:16
Real name: Krzysztof Grzelak

Re: Scan

Post by Krzysztof Grzelak » Sun Oct 25, 2015 11:49

At the very beginning I thank you for Gui Bert. Unfortunately, not everything is working properly. It does not work properly record party, unfortunately you need to improve. The program after saving the party does not show the correct beat, so x. Please make a DXP program.

Post Reply