Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about local and global variables

Author: Odd Gunnar Malin

Date: 13:28:00 09/02/01

Go up one level in this thread


On September 02, 2001 at 12:29:40, Bruce Moreland wrote:

>On September 02, 2001 at 07:29:12, Uri Blass wrote:
>
>>My question is when it is a good idea to define global variables
>>instead of local variables
>
>If your program is new, don't worry about this kind of nonsense yet.  You
>probably have huge performance gains that can be made because functions that are
>simply inefficient, and you can probably get huge performance gains by ordering
>moves better and pruning crap out of your tree.
>

I just want to mention an incident that happened to me the other night.
Be aware that I’m new to thinking of speed when programming (e.g. my first
chessengine).

In my routine for finding attacked squares I looped through the board for
finding a piece with the right color. And when I find one I made moves for it
and looked at the 'to square' to see if it hit the square in question.

So after I had lay down one night a lightning was hitting my head. Why not put a
bishop, rook etc. on the square in question and see if it hit it self. Of course
I had to try it once and it really made a speed up in the move generation of 2-3
times.

I'm sure this is known knowledge but as a stubborn I am I don’t want to study
other codes and only read text pages on chess programming. There even could be a
lot better methods to do the attack routine too. For me the programming it self
is the fun part and not the result.

When I tested my new move generation routine in real play it was not giving me a
whole ply longer search, so when a 200-300% speedup gives such a result there
could not be much gained in fiddling with compiler options, local/global
variables etc. that gives under 10% speedup. I guess the best is to live after
the KISS principle and run the code through a profiler only before it shall be
released.

I would believe that this was not the last lightning that are hitting me in this
field.

Odd Gunnar Malin



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.