Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: First Chess Program

Author: Dann Corbit

Date: 19:55:05 11/26/01

Go up one level in this thread


On November 26, 2001 at 22:40:39, Russell Reagan wrote:

>So what is the advantage of using callback functions? Is it faster or more
>organized or easier to design the engine or what?

First, it allows functions to be easily replaceable.  So (for instance) you
might easily swith MTD(f) for NegaScout by change of function.

More importantly, it allows for the program to be event driven.  It's usually
easier to understand than a typical FSM, especially if only some small portion
of the program needs to be event driven.

It also allows a program to be very generic.  Look at the implementation of
qsort() in the C standard library, and try to imagine how you would write a
function that allows you to sort an array of structs, ints, doubles, strings,
pointers to union, etc. without using a callback like the compare function
needed by qsort() and it will quickly come to your mind how helpful they can be.



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.