[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] Patch: improve separation of similarly-valued moves

From: Gunnar Farnebäck
Subject: Re: [gnugo-devel] Patch: improve separation of similarly-valued moves
Date: Thu, 22 Apr 2004 02:48:54 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI)

Evan wrote:
> Now, a question about my patch...  I included math.h in play_gtp.c, to
> get the log2 function.  Are there any objections to this?
> Unfortunately, it doesn't seem to work on my system.  I get:
> play_gtp.c: In function `gtp_move_uncertainty':
> play_gtp.c:3782: warning: implicit declaration of function `log2f'
> Am I doing something wrong, or is my system messed up in some strange
> manner?

As far as I can tell that should be perfectly correct but I do indeed
get the same problem. On the other hand, even if it worked there may
be portability issues with log2f(). My suggestion is to rewrite the
function like this (untested):

static int
gtp_move_uncertainty(char *s)
  float probabilities[BOARDMAX];
  int pos;
  double uncertainty = 0.0;



  /* Compute the uncertainty as the entropy of the move probability
   * distribution, H = -sum(p*log(p)).
  for (pos = BOARDMIN; pos < BOARDMAX; pos++)
    if (ON_BOARD(pos) && probabilities[pos] > 0.0)
      uncertainty -= probabilities[pos] * log((double) probabilities[pos]);

  /* Convert the unit to bits. */
  uncertainty /= log(2.0);

  return gtp_success("%.4f", uncertainty);

Hopefully there are not too many portability issues with the basic
log() function.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]