PGN reader

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: PGN reader

Post by Don »

Michael Sherwin wrote:
wgarvin wrote:
Michael Sherwin wrote:I do not have the time and energy to throw darts to find a decently good (for me) GUI language. I just want something simple, fast enough, focused, reasonably small and well documented with lots of examples. If there are good 3rd party books written about it, then all the better.

Given my needs, what is best for me? :?
Another option is to download the free version of Microsoft Visual C# Express Edition and write the GUI in C#. WinForms is far easier to use than anything from the win32 days. Its not "portable" (or at least I have no idea what level of support Mono has for it), but with GUI toolkits you can usually have at most two out of three: portable, simple and useful. WinForms is simple and useful (as opposed to Qt and wx which are portable and useful, or something like TCL which is portable and simple...)

Someone with some knowledge of C# and WinForms could build a functional GUI app with a bunch of buttons, menus, widgets etc. in less than an hour. Someone who's never used it before could probably do the same in a few hours. The designer lets you drag and drop widgets where you want them, and edit all of their properties. It generates C# code for them so that you can access them programmatically. It helps you create methods to handle the various events from the widgets that you're interested in, and you can then put whatever code you want into them.
Interesting. What is missing from TCL that would be needed for a chess interface? Or, in general, why is it not useful?
tcl/tk is a powerful and simple cross-platform GUI and language. You can also package up the code in executable format, so that a single exe can be delivered on windows or on linux or macs. It's a complete solution.
alpha123
Posts: 660
Joined: Sat Dec 05, 2009 5:13 am
Location: Colorado, USA

Re: PGN reader

Post by alpha123 »

Ahem, you guys are skipping Java. The NetBeans GUI Builder is quite nice. And Swing is powerful, simple, and useful. Yeah, I'm a Java guy.

Peter
ironchess

Re: PGN reader

Post by ironchess »

This is from http://chess.verhelst.org/1997/03/10/representations/ :
Minimal coding

When using 4 bits per square, an array representation will have a total size of 256 bits. It is possible to squeeze a chess position in less bits by using Huffman coding techniques. For example (C is colour of the piece):



Empty square: 0

Pawn: 10C

Bishop: 1100C

Knight: 1101C

Rook: 1110C

Queen: 11110C

King: 11111C


This gives a total size of 32 + 48 + 20 + 20 + 20 + 12 + 12 = 164 bits. Some additional bits will be necessary to indicate castle status and side to move.
Where do the numbers in the sum come from (32 +48+20 ...)?

Thank you in advance for your answer.
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 7:45 pm
Location: Finland

Re: PGN reader

Post by ilari »

ironchess wrote: Where do the numbers in the sum come from (32 +48+20 ...)?

Thank you in advance for your answer.
It's the size of a position where all the pieces are still on the board.
32 bits (32 empty squares) + 48 bits (16 pawns) + 20 bits (4 bishops) ...
aberent

Re: PGN reader

Post by aberent »

Have a look at the Computer Chess Blog. It has some code samples that include PGN parsing.

Adam
lukasmonk
Posts: 45
Joined: Sun Feb 07, 2010 7:35 pm
Location: Spain

Re: PGN reader

Post by lukasmonk »

A good choice is python and PyQt.
To work with texts python is the best language I know.
I have an open source program (lucas chess), one option is to read pgn, is not very elaborate but can give you an idea of what can be done with python and PyQt.