Chess for Android upcoming network feature

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Chess for Android upcoming network feature

Post by abik »

An upcoming release of Chess for Android will make "network socket engines" first class citizens, i.e. with support for all features that ordinary third party engines enjoy (including saving the options that were selected during first import, excluding the host:port). This will make it possible to run tournaments between locally running engines, and an engine running on a much more powerful remote chess server. Folkert van Heusden found an interesting alternative use of this feature for his engine POS. Since POS is written in Java which he could not easily convert into a stand-alone ARM binary, he wrote an Android wrapper around POS that acts as a chess server, named PosForAndroid, but running locally. This way, he can import POS in Chess for Android. I am running some tests tournaments and will post some results shortly.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess for Android upcoming network feature

Post by hgm »

Normally people use ssh for this: just run ssh + connection information as the engine command. Then you don't have to write anything. Of course I don't know if Android supports anything like ssh.
flok

Re: Chess for Android upcoming network feature

Post by flok »

hgm wrote:Normally people use ssh for this: just run ssh + connection information as the engine command. Then you don't have to write anything. Of course I don't know if Android supports anything like ssh.
Don't have to write anything? No idea why you think that.
I think most of the work is in the user-interface, not neccessarily the networking. Due to the inheritance-features of java, one would only need to sublass the uci-/xboard-code and replace the send/receive methods. For ssh, you would not only need to enhance the connect, send and receive methods (with considerable amounts of code, see http://www.ganymed.ethz.ch/ssh2/), you would also need to add code which understands how to invoke binaries on a remote system (with the correct (command line-)parameters!), you would need to add password- and/or public key authentication, etc. etc. while a simple network socket would be only a matter of letting an engine listening on a socket instead of a pipe or interfacing an engine to netcat.
Well, maybe Aart can add it as well, this ssh support. Maybe it is usefull but there's the risk of the program getting bloated. We're talking Android here so memory and "disk"-space is limited.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess for Android upcoming network feature

Post by hgm »

Well, I have never done this myself, but isn't it simply matter of specifying

ssh user@system 'fairymax'

as engine command in the local GUI in order to run Fairy-Max as an engine on the remote system (after logging in there as 'user')?
flok

Re: Chess for Android upcoming network feature

Post by flok »

hgm wrote:Well, I have never done this myself, but isn't it simply matter of specifying
ssh user@system 'fairymax'
as engine command in the local GUI in order to run Fairy-Max as an engine on the remote system (after logging in there as 'user')?
No it is not.
- fairymax might need specific parameters
- user might need to enter paths, environment variable settings (e.g. for libraries which are not in the search-paths so to say)
- user must enter a password which must be securely remembered for the duration of tournaments
- password authentication might not be enabled on the ssh-server, causing the need for a public key authentication. this requires the secret key to be installed on the android. this key might be protected with a password.
- you need to give the user the ability to enable/disable compression of the stream to reduce costs
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess for Android upcoming network feature

Post by hgm »

Well, fairymax doesn't need parameters and should normally be in the path (on Linux) But even if it would, you would just give them with the comand:

ssh user@system '/home/user/chess/mypolyglot -noini -ec /home/user/chess/myfruitclone'

would run mypolyglot + myfruitclone (presumably a UCI engine).

Obviously the host machine would have to be configured as a server, and the engine would have to be installed on it. This might as well be done properly, configuring the engine such that it knows how to find the data files and libraries it needs. Putting this burdon on users that connect seems a really bad idea.

As to authentication, I understood that ssh will take care of all that (when you properly configure it). No need to let the GUI do it. In the end you will always have to configure something. Passwords or public keys don't materialize out of thin air. So you might as well configure ssh directly (which was designed for exactly that job).

Compressing the data stream seems hardly worthwile.
flok

Re: Chess for Android upcoming network feature

Post by flok »

Don't forget we're talking smartphone here.
You can't expect a regular user to configure an ssh client on such a platform. That would require all kinds of trickery. Not only because ssh is not installed by default on Android (or any other smartphone). So you would need to put it on an sd-card or so which then would require setting pathnames etc.

Furthermore this network-interface can also be used for chess engines that can't be directly invoked from within the board-program. On Android, one can only do a popen-like construction with native binaries, not for Dalvik (java)-code.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: Chess for Android upcoming network feature

Post by Daniel Shawul »

You can pass parameters and environment variables if you use the correct exec exec(String[] cmdarray, String[] envp, File dir) . So the first two are not a problem. That is what I use in my android app so I believe it should work even though I never tried it. SSH public key authentication and password may require further handling but that is a one time setup (i.e during engine install).
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess for Android upcoming network feature

Post by hgm »

flok wrote:Don't forget we're talking smartphone here.
You can't expect a regular user to configure an ssh client on such a platform. That would require all kinds of trickery. Not only because ssh is not installed by default on Android (or any other smartphone). So you would need to put it on an sd-card or so which then would require setting pathnames etc.
This seems a bit of a weak argument, because whatever you might write yourself, no matter how fancy, will also not be installed by default on Android...

But my original point was that ssh can be used to run engines remote without having to write any code. We now seem to have drifted away from that. Copying something to an SD card, or providing a password / key is not what I would consider writing code...
flok

Re: Chess for Android upcoming network feature

Post by flok »

hgm wrote:
flok wrote:Don't forget we're talking smartphone here.
You can't expect a regular user to configure an ssh client on such a platform. That would require all kinds of trickery. Not only because ssh is not installed by default on Android (or any other smartphone). So you would need to put it on an sd-card or so which then would require setting pathnames etc.
This seems a bit of a weak argument, because whatever you might write yourself, no matter how fancy, will also not be installed by default on Android...
When I wrote that, I was thinking that installing ssh would be cumbersome, difficult and tricky. But I did not realize that you could package it as any regular android package.
Well, no you can't: program x can't access the files of program y - as you see I think while I write :-). So it would then be easier to integrate an ssh client in the chess board application as otherwhise you would need to let the user install it on the sd-card somehow and tell the program where it installed it. In both cases you would need to tell ssh where it can find password/key-files etc.