Author: Russell Reagan
Date: 18:22:53 04/21/02
Generally when I ask around (besides here) about chess programming questions I don't get very good answers, because I don't think most other programmers understand computer chess. Normally something like this wouldn't even matter, but because of the nature of chess programs repetitive nature in a handful of short functions it seems like a possibly more important issue. My specific question is about whether it's faster to use a struct for your position, or to simply have some global variables. Global variables seem like they would be faster because you don't have to dereference the pointer. I'm not sure how costly dereferencing a pointer is or if it even costs anything, but if it costs even an extra instruction, and you do a dozen dereferences in your make move and unmake move functions, and quite a few in your evaluation function, and multiply how many dereferences you do by how many nodes you do in a normal search, that's a lot of wasted instructions. So is it faster to pass a pointer to a position structure around to all of your makemove, unmakemove, evaluation, etc. functions or to have some global variables that the program acts upon? If it is faster to use global data, is the speed difference trivial? For example, if you save a lot of instructions from using global data, but it only gets you another 1000 nodes in a 60 second search it's not a huge difference. What are some basic things that I do to write efficient code? Basic rules, such as pass a pointer instead of a copy of the entire structure. Things like that. And how could I test something like this in the future? For example, if I want to find out the cost of dereferencing a pointer. Where can I learn about these kinds of basic computer computational kinds of things? Any book or website recommendations? I'm a product of growing up with Microsoft so I was never really exposed to the more basic lower level computer issues like some of you guys who were writing chess programs in the 70's before I was born :) Thanks for any help and advice you can offer. Russell
This page took 0.01 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.