Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Open Source Chess Programs

Author: William Hoggarth

Date: 10:38:51 06/08/05

Go up one level in this thread


On June 08, 2005 at 06:29:49, Tord Romstad wrote:

>Sounds easy in theory, but I have found that it is not quite that easy in
>practise.

Really? It's not been my experience. I suspect its just a matter of getting into
the habit.

>There is also another reason I don't like having a lot of comments in my
>code:  I find it much easier to read code when I can see as many lines of
>code as possible without moving my eyes around or scrolling up and down.
>Comments therefore often actually *reduce* the readability of the code,
>in my eyes.  For similar reasons, I usually don't have a lot of vertical
>whitespace in my code.

I think for someone familiar with chess code in general and with Glaurung in
particular Dan and yourself may well be correct. But you need to think in terms
how reading the code is for others, not for yourself. I think that's why opinion
differs from that of yours and Dans.

Perhaps Uri's suggestion of having some separate documents would be the way to
go. A file explaining some of the key ideas, structures, macros and functions
would go a very long way. Then all you would have to do is check and update it
just before each release.

>Good code should be self-documenting
>and understandable with just a few comments.

I agree with that. It's code and comment quality rather than comment quantity.
However, the idea that code is self-documenting without appropriate comments is
nonsense.

>I mostly try to use macros or functions for this kind of stuff.  That is
>why I have definitions like this:
>
>#define FriendlyPawn (PAWN|(Side<<3))
>
>There is no doubt, however, that in many cases I have been too lazy about
>this.  I should try to clean this up and use more such macros in future
>versions.

An excellent idea ;)

>#define FriendlyPawn PieceOfTypeAndColour(PAWN, Side)
>
>I think the name PieceOfTypeAndColour is too long and cryptic, though.
>Better suggestions are welcome.

I don't think the name is cryptic, it does what it says on the tin. It probably
is a bit on the long side though as it may make some expressions rather
unwieldily. You should be able to see what is being passed, as is the case here,
so you may be able to drop part of the name eg:

PieceOfColour or PieceOfType (or even PieceFrom??)



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.