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: Tue, 20 Apr 2004 12:38:23 -0400
User-agent: Mozilla Thunderbird 0.5 (X11/20040306)

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

Paul Pogonyshev wrote:
| Here we are.
|
| - new function compute_move_probabilities() in `value_moves.c'
| - new GTP command `move_probabilities'
|
| It would be nice if anyone made use of this in a test suite.  You
| will likely have to implement more GTP commands (or change the one
| I added).

- - new GTP command 'move_uncertainty'

This patch adds the command move_uncertainty, which returns the
uncertainty of the move, in bits.  This has the convenient property that
the uncertainty across many moves can be calculated individually per
move, and then added together to get a meaningful result.

Note that for both Paul's move_probabilities command and
move_uncertainty, you must execute some form of genmove command
immediately prior in order to set up the move values.  Should this be
changed?

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?

Thanks

Evan Daniel

(Thunderbird seems to want to wrap lines, so I've attached the patch.
I'll look into it, but let me know if that causes a problem for now.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAhVH/0OcbTJFOafIRAvI2AJ9vFBHKXrp2ahvvuD15sPt/UKnKdQCdGr1g
1ZD4GvcTtSNAgVYxKeCoX88=
=H9MR
-----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        20 Apr 2004 16:26:24 -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},
@@ -3764,2 +3767,25 @@
 
+static int
+gtp_move_uncertainty(char *s)
+{
+  float probabilities[BOARDMAX];
+  int pos;
+  float 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) {
+      uncertainty += -1 * probabilities[pos] * log2f(probabilities[pos]);
+    }
+  }
+
+  gtp_printf("%.4f\n\n", uncertainty);
+
+  return GTP_OK;
+}
+
 

reply via email to

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