Prefer debugging over speed (heavily) in gnugo, and got the board into a stronger state, to align with how gnugo does things.

This commit is contained in:
Anna Rose 2012-04-13 01:38:58 -04:00
parent 46187886ed
commit 18e14f61e6
4 changed files with 47 additions and 26 deletions

5
gnugo/configure vendored
View File

@ -2909,6 +2909,9 @@ fi
CFLAGS=""
CPPFLAGS="-fPIC -O0 -g3"
# Check whether --with-readline was given.
@ -5540,8 +5543,6 @@ fi
#AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
CPPFLAGS="$CPPFLAGS -fPIC"
ac_config_files="$ac_config_files Makefile interface/Makefile patterns/Makefile sgf/Makefile utils/Makefile engine/Makefile doc/Makefile regression/Makefile config.vc:config.vcin"
cat >confcache <<\_ACEOF

View File

@ -29,6 +29,9 @@ AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE")
AM_MAINTAINER_MODE
CFLAGS=""
CPPFLAGS="-fPIC -O0 -g3"
dnl See if user has expressed a preference for use of curses and/or color
dnl These set variables $enable_color and $with_curses to "no" if disabled
dnl "yes" if enabled, or undefined if not specified
@ -586,7 +589,5 @@ dnl FIXME:
dnl autoconf 2.50 recommends AC_CONFIG_FILES and AC_OUPUT
dnl This however requires automake 1.4p2 or better
CPPFLAGS="$CPPFLAGS -fPIC"
AC_OUTPUT([Makefile interface/Makefile patterns/Makefile sgf/Makefile
utils/Makefile engine/Makefile doc/Makefile regression/Makefile config.vc:config.vcin])

View File

@ -77,8 +77,7 @@ class Goban:
def play_move(self, pos, color=None):
"""Make a move."""
x,y = pos
realpos = x*19 + y
realpos = _real_pos(pos)
if color is None:
color = self.to_move
@ -97,8 +96,7 @@ class Goban:
def set_hover(self, pos):
x,y = pos
realpos = x*19 + y
realpos = _real_pos(pos)
if self.hover == realpos:
return
@ -133,13 +131,20 @@ class Goban:
inc = size / 19
p = c_int * 361
p = c_int * 421
board = p.in_dll(Goban.libboard, 'board')
for pos in range(361):
s = img_res[self._get_draw_code(pos, board[pos])]
for pos in range(421):
if _i(pos) < 0 or _j(pos) < 0:
continue
code = self._get_draw_code(pos, board[pos])
if code == 'e':
continue
s = img_res[code]
s = pygame.transform.scale(s, (inc, inc))
ret.blit(s, ((pos%19)*inc, (pos/19)*inc))
ret.blit(s, (_i(pos)*inc, _j(pos)*inc))
if self.hover == pos:
c = img_res['bH']
@ -147,7 +152,7 @@ class Goban:
c = img_res['wH']
c = pygame.transform.scale(c, (inc, inc))
ret.blit(c, ((pos%19)*inc, (pos/19)*inc))
ret.blit(c, (_i(pos)*inc, _j(pos)*inc))
return ret.convert_alpha()
@ -182,23 +187,37 @@ class Goban:
return 'b'
if board_value == Goban.WHITE:
return 'w'
if pos == 0:
if _i(pos) == 0 and _j(pos) == 0:
return 'ul'
if pos == 18:
if _i(pos) == 18 and _j(pos) == 0:
return 'ur'
if pos == 342:
if _i(pos) == 0 and _j(pos) == 18:
return 'dl'
if pos == 360:
if _i(pos) == 18 and _j(pos) == 18:
return 'dr'
if pos in [60, 66, 72, 174, 180, 186, 288, 294, 300]:
if (_i(pos), _j(pos)) in [(3,3), (3,9), (3,15), (9,3), (9,9), (9,15), (15,3), (15,9), (15,15)]:
return 'h'
if pos < 18:
return 'u'
if pos % 19 == 0:
if _i(pos) == 0:
return 'l'
if pos > 341:
return 'd'
if pos % 19 == 18:
if _i(pos) == 18:
return 'r'
if _j(pos) == 0:
return 'u'
if _j(pos) == 18:
return 'd'
else:
return 'm'
# This is equivalent to gnugo's POS macro
def _real_pos(pos):
x,y = pos
return 21 + x * 20 + y
def _i(pos):
return (pos / 20) - 1
def _j(pos):
return (pos % 20) - 1

View File

@ -100,7 +100,7 @@ def main():
col = x / board_inc
if x <= board_size:
goban.set_hover((row,col))
goban.set_hover((col,row))
else:
goban.clear_hover()
@ -112,7 +112,7 @@ def main():
if x <= board_size:
if event.button == 1:
goban.play_move((row, col))
goban.play_move((col, row))
board = goban.draw_board(board_size, img_res)