# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# This is GNU Go, a Go program. Contact gnugo@gnu.org, or see #
# http://www.gnu.org/software/gnugo/ for more information. #
# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, #
# 2008 and 2009 by the Free Software Foundation. #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation - version 3, #
# or (at your option) any later version. #
# This program is distributed in the hope that it will be #
# useful, but WITHOUT ANY WARRANTY; without even the implied #
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR #
# PURPOSE. See the GNU General Public License in file COPYING #
# You should have received a copy of the GNU General Public #
# License along with this program; if not, write to the Free #
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, #
# Boston, MA 02111, USA. #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Database of connection patterns.
# X - opposite color of O
# O - color of dragon looking for connection
# * - cutting point in the O formation, an X move here must be
# ! - inhibit connection, eye space points for O are turned marginal
###################################
# The connection database contains patterns of three different classes,
# which also are matched separately.
# B - Indicate cutting points and inhibit connections.
# C - Amalgamate worms into dragons.
# Additionally there are a few acceptance modifiers.
# s - Accept even if the pattern includes tactically unsafe strings
###################################
# The connection database is organized into a number of different
# categories and ordered so that more specific patterns are matched
# before more general ones, since evaluating the constraints of the
# latter usually is expensive.
# Lunch - patterns that invalidate lunches, matched with I patterns
###################################
# callback_data is dependent on pattern class in this database
##########################
# B patterns in the center
##########################
?O. fragile double connection
?.. fragile double connection
;&& !oplay_disconnect(c,b)
;&& !xplay_connect(*,a,b)
# This pattern is used to find potential cutting stones as defined by
# the field cutstone2 in the worm data. The helper returns 0 so the
# pattern doesn't fire as a B pattern.
# tm New Pattern (3.1.23) (see global:17, )
# careful not to break trevord:730
# FIXME: Need to use amalgamate_most_valuable helper.
# xplay_disconnect helper also might be useful here.
# gf Revised constraint. (3.3.13)
x* fragile double connection
;xplay_connect(a,b) && !xplay_connect(*,a,b)
!*? fragile double connection
X.X workaround for ko contingent connection
;xplay_attack(*,A)<WIN && !xplay_connect(*,?,b,c,d)
# Static connections need almost everything
##########################
# C patterns in the center
##############################################
# CC1xx - patterns without reading constraints
##############################################
# Static connections need almost everything
;omoyo(a) && oarea(c) && oarea(f)
;&& ((omoyo(b) + omoyo(c) + omoyo(d) + omoyo(e) + omoyo(f) +omoyo(g)) >= 3)
# gf Revised constraint. (3.3.3)
;omoyo(a) && omoyo(b) && lib(c)>=4 && lib(d)>=4
##########################################################
# CC2xx - patterns with reasonably inexpensive constraints
##########################################################
#############################################
# CC3xx - patterns with expensive constraints
#############################################
# CC30x - one space jump connections
####################################
###########################
# CC31x - keima connections
###########################
####################################
# CC32x - two space jump connections
####################################
############################
# CC33x - ogeima connections
############################
####################################################################
# CC4xx - fragile double connections
# FIXME: These shouldn't be matched until all other amalgamation has
####################################################################
# Do amalgamate one of the two possible connections. We guess that
# the larger of the two dragons is the one we most want to keep in
?O. fragile double connection
>amalgamate_most_valuable_helper(b,c,d);
# Do amalgamate one of the two possible connections. We guess that
# the larger of the two dragons is the one we most want to keep in
?.. fragile double connection
>if (!xplay_attack_either(b,c,d,b,d) || !xplay_attack_either(c,b,a,c,a))
> amalgamate_most_valuable_helper(e,f,g);
####################################################################
# CC5xx - experimental connection patterns
####################################################################
# Note about patterns CC501, CC502, CC502b, CC511
# In theory, these patterns go against the connection policy that the
# involved strings must be tactically stable (not capturable) and
# consequently, they should not be needed at all. In practice though,
# problems arise with the optics/owl analysis when such strings aren't
# amalgamated. An example (see owl:50)
# In the absence of the mentioned patterns, the topmost X stone would
# NOT be amalgamated with the others, because all attempts at
# defending these kosumi connections result in a tactical capture of
# the whole string, thus a successful cut.
# As a consequence, the owl code would be run against separate targets,
# and in the above case, it would even fail to find a way to kill the
# topmost X stone (the lack of context is then responsible for the
# optics/owl code not being able to return vital points)
####################################################################
# Connect even if stones not tactically safe.
# Connect even if stones not tactically safe.
;lib(a)>1 && lib(b)>1 && !xcut(c) && xlib(c)==1 && xplay_attack(c,c)==WIN
# Connect even if stones not tactically safe.
;lib(a)>1 && lib(b)>1 && !xcut(c) && !xcut(d)
;&& xlib(c)==1 && xplay_attack(c,c)
;!xcut(a) && !disconnect_helper(b,c)
;!xcut(a) && !disconnect_helper(b,c)
;((attack(A) && !distrust_tactics_helper(A))
; || (attack(B) && !distrust_tactics_helper(B)))
;&& !disconnect_helper(c,d)
;!xcut(a) && !xcut(b) && !disconnect_helper(c,d)
;!xcut(a) && !xcut(b) && lib(E)<=2 && !disconnect_helper(c,d)
;!xcut(a) && !xcut(b) && !disconnect_helper(c,d)
;!xcut(a) && !disconnect_helper(b,c)
;!xcut(a) && !xcut(b) && !xcut(c) && !xcut(d) && !disconnect_helper(e,f)
# Connect even if stones not tactically safe.
;attack(a) && attack(b) && !xcut(c) && !xcut(d)