Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: advantages to board pointers

Author: Eric Oldre

Date: 13:44:30 06/10/04

Go up one level in this thread


On June 10, 2004 at 16:33:03, Dann Corbit wrote:

>There are two reasons you might want to use pointers:
>
>1.  You don't know how big something will be before hand.  E.g. a hash table.
>
>2.  You want to pass it as quickly as possible and the pointer is smaller than
>the object.  For instance, if I have a 500 byte object and a pointer is 4 bytes,
>then passing a pointer will push and copy 4 bytes {the address of the object}
>instead of 500 bytes {the object itself}.
>
>The functionality of things does not hinge on whether you have the object or a
>pointer to it.

Thanks for the fast response Dann.

I do understand what the reasons to use pointers in a program in general are
(somewhat). But what I'm more interested in is the experiece people have had
passing pointers to a board in a chess program specifically. And the tradeoffs
they may have considers when choosing to either of the ideas described below.


//example, not passing a pointer, using global board;

extern chessboard board;
int search(int depth, int alpha, int beta); //searches from current position of
global board.
void move_make(chessmove move); //applies move to global board.



//example, passing a pointer to a board

int search(chessboard *board, int depth, int alpha, int beta);
void move_make(chessboard *board, chessmove move); //applies move to board at
address of *board


(ps. in the crafty implentation, i think he's not actually passing a pointer to
a board. but to some other stucture that holds a board among other things)




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.