Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Search question: returning "more"

Author: Robert Hyatt

Date: 18:44:20 12/15/02

Go up one level in this thread


On December 15, 2002 at 16:12:30, Russell Reagan wrote:

>Most examples of search functions that I have seen involve returning the result
>by value, usually an int. I'd like to know how to go about arriving at a result
>that contains more information that a simple int can hold. For example, if I
>have a struct like this:
>
>typedef struct search_result_tag {
>    // pv stuff
>    move moves[MAX_MOVES];
>    int num_moves;
>    // evaluation stuff
>    int overall_score;
>    int material;
>    int mobility;
>    int king_safety;
>    // search stuff
>    int full_width_depth;
>    int qsearch_depth;
>    int time;
>    // etc...
>} search_result;
>
>How do I pass that around correctly in a recursive search function? The only
>example remotely similar is Bruce Moreland's "Collecting the Principal
>Variation" (http://www.seanet.com/~brucemo/topics/pv.htm).
>
>In general I tend to get lost in the recursiveness of trying to figure this out.
>I'm also unsure about where to update some of these values during the search.
>For example, to determine qsearch_depth I was doing something like (on paper)
>"result->qsearch_depth++;" in the search function, but then I realized that was
>nothing more than node counting, not depth counting.
>
>So not only would I like a little help about how to pass this thing around
>correctly (do you keep passing the same pointer, or do you make copies, or
>something else?), but I'd also appreciate a little guidance as to determining
>when to update different things.
>
>Thanks,
>Russell


You can pass a structure just like you pass a simple variable.  Either by
value or by address...  It can be expensive as pass by value passes things
on the stack which means a lot of memory traffic...




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.