Object model for chess GUI?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Rein Halbersma
Posts: 741
Joined: Tue May 22, 2007 11:13 am

Re: Object model for chess GUI?

Post by Rein Halbersma »

hgm wrote:Beware that writing a GUI is between 10 and 100 times more work than writing an engine.
Could you give some reasoning behind this claim? What makes it so hard? (I have no experience in writing GUIs, so honest question here). Is it the logic, the graphical layout stuff, or something else? Do you use any high-level libraries?

From what I have read, things like Qt should not be that hard to get off the ground, e.g. with their scripting tool QML (and Microsoft has similar stuff with XaML) that is preprocessed into compilable C++ one should be able to get a bunch of windows / menus with little code.
User avatar
gbtami
Posts: 389
Joined: Wed Sep 26, 2012 1:29 pm
Location: Hungary

Re: Object model for chess GUI?

Post by gbtami »

Rein Halbersma wrote:
hgm wrote:Beware that writing a GUI is between 10 and 100 times more work than writing an engine.
Could you give some reasoning behind this claim? What makes it so hard? (I have no experience in writing GUIs, so honest question here). Is it the logic, the graphical layout stuff, or something else? Do you use any high-level libraries?

From what I have read, things like Qt should not be that hard to get off the ground, e.g. with their scripting tool QML (and Microsoft has similar stuff with XaML) that is preprocessed into compilable C++ one should be able to get a bunch of windows / menus with little code.
It's not "so hard". It only needs huge amount of work.If you have a good chess lib creating a _simple_ GUI is not so complicated. You can study a nice one here: https://github.com/cutechess/cutechess/ ... r/projects

But bringing it to a level where popular/top GUIs are stay needs several years of additional work.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Object model for chess GUI?

Post by Sven »

Rein Halbersma wrote:
hgm wrote:Beware that writing a GUI is between 10 and 100 times more work than writing an engine.
Could you give some reasoning behind this claim? What makes it so hard? (I have no experience in writing GUIs, so honest question here). Is it the logic, the graphical layout stuff, or something else? Do you use any high-level libraries?

From what I have read, things like Qt should not be that hard to get off the ground, e.g. with their scripting tool QML (and Microsoft has similar stuff with XaML) that is preprocessed into compilable C++ one should be able to get a bunch of windows / menus with little code.
I think he is right with those "10 to 100 times". Among the reasons are:

- Even using the best GUI framework means more work than using - nothing (which is what most engines are doing: elementary programming without much need for any library).

- Writing portable engines is easy. Writing portable GUIs is not. Different OS's, maybe different versions of runtime libs installed, different display resolutions, ...

- A GUI shall be used by someone. Therefore you need to test a lot, and users will still complain that it does not match their expectations. Engines, on the contrary, have a well-defined interface. Of course you also have a lot of work to improve, tune, polish, or maintain your chess engine, maybe lasting for years. But I think the "10 to 100 times" was meant for the initial creation of a correctly working GUI that is also *good*. Top GUIs set a standard, and people tend not to accept something below the standard that the already know from other GUIs, so you must at least reach the current state-of-the-art to make people use your GUI. Otherwise it stays a "simple" GUI, subjectively. That can certainly be created faster.

- Writing a GUI needs more design work: graphical design as well as software design.
Rein Halbersma
Posts: 741
Joined: Tue May 22, 2007 11:13 am

Re: Object model for chess GUI?

Post by Rein Halbersma »

Sven Schüle wrote:I think he is right with those "10 to 100 times". Among the reasons are:

- Even using the best GUI framework means more work than using - nothing (which is what most engines are doing: elementary programming without much need for any library).

- Writing portable engines is easy. Writing portable GUIs is not. Different OS's, maybe different versions of runtime libs installed, different display resolutions, ...

- A GUI shall be used by someone. Therefore you need to test a lot, and users will still complain that it does not match their expectations. Engines, on the contrary, have a well-defined interface. Of course you also have a lot of work to improve, tune, polish, or maintain your chess engine, maybe lasting for years. But I think the "10 to 100 times" was meant for the initial creation of a correctly working GUI that is also *good*. Top GUIs set a standard, and people tend not to accept something below the standard that the already know from other GUIs, so you must at least reach the current state-of-the-art to make people use your GUI. Otherwise it stays a "simple" GUI, subjectively. That can certainly be created faster.

- Writing a GUI needs more design work: graphical design as well as software design.
Some Q&As from Stackoverflow
http://stackoverflow.com/questions/5140 ... developers
http://stackoverflow.com/questions/7465 ... -this?lq=1
User avatar
Steve Maughan
Posts: 1221
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Object model for chess GUI?

Post by Steve Maughan »

Hi Rein,

Thanks for the links.

I have experience designing GUIs. The most advanced being AlignMix, my sales territory mapping application. See here:

https://www.alignmix.com

Steve
http://www.chessprogramming.net - Maverick Chess Engine
Rein Halbersma
Posts: 741
Joined: Tue May 22, 2007 11:13 am

Re: Object model for chess GUI?

Post by Rein Halbersma »

Steve Maughan wrote:Hi Rein,

Thanks for the links.

I have experience designing GUIs. The most advanced being AlignMix, my sales territory mapping application. See here:

https://www.alignmix.com

Steve
So what tools do you use? Do you agree with HGM's 10-100x estimate of development costs?
User avatar
Steve Maughan
Posts: 1221
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Object model for chess GUI?

Post by Steve Maughan »

Hi Rein,

Creating a GUI is definitely a big task. To create a GUI like Shredder or Fritz is almost certainly x10 more work than creating a basic engine. However I really doubt it's any more work than creating a top engine such as Komodo.

The big difference between creating an engine and a GUI is that developing an engine will involve code which turns out to be useless. This also occurs in GUI design, bit to a lesser degree.

I code GUIs in Delphi / Object Pascal. IMHO this is the most productive environment for creating high quality GUIs. Arena is written in Delphi,

Steve
http://www.chessprogramming.net - Maverick Chess Engine
User avatar
hgm
Posts: 27811
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Object model for chess GUI?

Post by hgm »

Rein Halbersma wrote:Could you give some reasoning behind this claim? What makes it so hard? (I have no experience in writing GUIs, so honest question here). Is it the logic, the graphical layout stuff, or something else? Do you use any high-level libraries?
Part of it is that you want the GUI to perform many different unrelated tasks, that thus share no code. It is also expected that a GUI would provide a complete implementation of everything so that it would work with any engine, rather than just a few, while engines that do not implement some features (such as pondering, multi-PV or move exclusion) would not draw much criticism.
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Object model for chess GUI?

Post by stegemma »

Steve Maughan wrote:I'm toying with the idea of writing a chess GUI. Does anyone have any suggestions for the object model / structure for a chess GUI? Are there any links wether this has been discussed?

Thanks, Steve
In Raffaela the interface were in VCL; I have wrote a component for the chessboard (that is of course a class) that only manage the graphic representation and calls the engine to handle move legality. Another VCL component manages the clock. In Raffaela I needed a class to embed the engine, that were in assembly, but in Satana the engine itself is a class derived from a generic engine base class (in C++). I suggest to write this generic engine class, that have virtual public functions that the program can call, to connect to the chessboard VCL component.

In Satana I have classes for the game, the players and so on but this a very complex structure; for a GUI, you must focus on the GUI itself, of course, that's why I suggest to have a generic engine class, that does almost nothing by itself.

The communication between the GUI and the engines should be encapsulated in another class and even this one should be initially only a virtual base class.

In Satana, I have both the engine and the core of a GUI working this way.
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Object model for chess GUI?

Post by lucasart »

Steve Maughan wrote: I'd write it in Delphi / Object Pascal, and use the VCL as the GUI framework.

After giving it a little thought it's not obvious as to what is the best way to construct the underlying structure.
Delphi is mostly dead, so you risk being left with a compiler and toolkit that are stuck in the 90s... Not to mention portability limitations.

And you have lots of wheels to reinvent. Instead, write it Python, using the chess library. It does all the heavy lifting for you:
https://pypi.python.org/pypi/python-chess
This library is truly amazing!
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.