gnugo-devel
[Top][All Lists]
Advanced

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

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


From: Evan Daniel
Subject: Re: [gnugo-devel] Patch: improve separation of similarly-valued moves
Date: Wed, 21 Apr 2004 23:25:57 -0400
User-agent: Mozilla Thunderbird 0.5 (X11/20040306)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gunnar FarnebXck wrote:

| 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):

That works on my system.  Does it work for other people?

Here's the updated patch.

Evan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAhztF0OcbTJFOafIRAtZDAJ4tnqg9z9EHHJiPfplkDvLaQPrXdQCfWhq/
SV7D+gFNeVVCSzZKGwJBiNc=
=DgZT
-----END PGP SIGNATURE-----
diff -u interface/play_gtp.c interface/play_gtp.c
--- interface/play_gtp.c        20 Apr 2004 15:34:30 -0000
+++ interface/play_gtp.c        22 Apr 2004 03:22:29 -0000
@@ -26,6 +26,7 @@
 #include <assert.h>
 #include <ctype.h>
 #include <string.h>
+#include <math.h>
 
 #include "interface.h"
 #include "liberty.h"
@@ -136,6 +137,7 @@
 DECLARE(gtp_move_influence);
 DECLARE(gtp_move_probabilities);
 DECLARE(gtp_move_reasons);
+DECLARE(gtp_move_uncertainty);
 DECLARE(gtp_name);
 DECLARE(gtp_owl_attack);
 DECLARE(gtp_owl_connection_defends);
@@ -275,6 +277,7 @@
   {"move_influence",          gtp_move_influence},
   {"move_probabilities",      gtp_move_probabilities},
   {"move_reasons",            gtp_move_reasons},
+  {"move_uncertainty",       gtp_move_uncertainty},
   {"name",                    gtp_name},
   {"new_score",               gtp_estimate_score},
   {"orientation",            gtp_set_orientation},
@@ -3765,0 +3769,34 @@
+/* Function:  Return the number of bits of uncertainty in the move.
+ * Arguments: none
+ * Fails:     never
+ * Returns:   bits of uncertainty
+ */
+static int
+gtp_move_uncertainty(char *s)
+{
+  float probabilities[BOARDMAX];
+  int pos;
+  double uncertainty = 0.0;
+
+  UNUSED(s);
+
+  compute_move_probabilities(probabilities);
+
+  gtp_start_response(GTP_SUCCESS);
+  for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
+    if (ON_BOARD(pos) && probabilities[pos] > 0.0) {
+      /* Shannon's formula */
+      uncertainty += -1 * ((double)probabilities[pos]) *
+       log((double)probabilities[pos]);
+    }
+  }
+
+  /* convert to bits */
+  uncertainty /= log(2.0)
+
+  gtp_printf("%.4f\n\n", uncertainty);
+
+  return GTP_OK;
+}
+
+

reply via email to

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