Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Thoughts about board representations...

Author: Dan Newman

Date: 21:42:25 02/13/00

Go up one level in this thread


On February 13, 2000 at 18:58:00, Tom Kerrigan wrote:

>On February 13, 2000 at 17:32:33, Dan Newman wrote:
>
>>I've wondered about this.  In isolation (which is usually when I end up
>>bloating my move generator like this) it's certainly faster to unroll loops,
>>etc., but once you get a bunch of other things put in this could of course
>>be a problem.  But whenever I fiddle around with this code, it just tends to
>>get slower...  I just looked at the .obj for the move generator and it's
>>14k and make/unmake is 16k (for the 0x88).  For the bitboard engine these
>>are even larger: 22k and 34 k resp.  They are in fact the largest modules
>>in the program with search coming in a close third...
>
>Yeah, unrolling loops can be good and bad.
>
>But in the code you posted, you unrolled a loop at the expense of a switch
>statement. I don't think this is a very good tradeoff.
>
>If you keep the entries in your piece list in order, you can possibly avoid the
>switch statement. Although this involves more code bloat.
>
>-Tom

Switch statements aren't as good as I'd like.  Ideally they'd just give you
a quick dispatch to the right piece of code, unfortunately they do a little
more work than is needed in this case.  I've looked at the code generated for
switch statements, and it would be much better if it didn't have to check the
argument for the default case--since I know there isn't one.  I looked for a
pragma or something to disable those extra, uneeded tests, but couldn't find
anything (MSVC 5.0).  There are occasions, though, when you can avoid multiple
if-tests and/or looping overhead by going to a switch statement form.  It's
also pretty straight forward and transparently easy to understand...

If I were to use multiple piece lists (one for each type) I could avoid
the switch statement too, but at some cost--don't know how it'd come out.
If I were to write another non-bitboard program I think I'd consider doing
that.  Bitboards are nice in this respect since you've got each piece type
segregated into its own bitboard--so you're not even faced with a choice :).

-Dan.



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.