Re: [Housebot-developers] SF.net SVN: housebot: [470] branches/ld_urbanhafner
Status: Alpha
Brought to you by:
j_house
|
From: Phil G <go...@th...> - 2007-02-18 17:59:58
|
Urban:=0A=0AIf you are looking for a reference implementation of Muller's t= hesis, I have some source code here:=0A=0Ahttp://www.thinkedge.com/MyGoBot2= =0Ahttp://www.thinkedge.com/MyGoBot2/MullerSolver.cs=0Ahttp://www.thinkedge= .com/MyGoBot2/ColorEnclosedRegion.cs=0A=0A=0A=0A----- Original Message ----= =0AFrom: "urb...@us..." <urb...@us...= .net>=0ATo: hou...@li...=0ASent: Saturday, Feb= ruary 17, 2007 8:44:14 AM=0ASubject: [Housebot-developers] SF.net SVN: hous= ebot: [470] branches/ld_urbanhafner=0A=0A=0ARevision: 470=0A http:= //svn.sourceforge.net/housebot/?rev=3D470&view=3Drev=0AAuthor: urbanhafne= r=0ADate: 2007-02-17 08:44:14 -0800 (Sat, 17 Feb 2007)=0A=0ALog Message= :=0A-----------=0AAdded directory for data structures and added the region = class that represents a region as described in Martin M?\195?\188ller's the= sis.=0A=0AModified Paths:=0A--------------=0A branches/ld_urbanhafner/Do= xyfile=0A branches/ld_urbanhafner/configure.ac=0A branches/ld_urbanha= fner/src/Makefile.am=0A=0AAdded Paths:=0A-----------=0A branches/ld_urba= nhafner/src/datastructures/=0A branches/ld_urbanhafner/src/datastructure= s/Makefile.am=0A branches/ld_urbanhafner/src/datastructures/region.cpp= =0A branches/ld_urbanhafner/src/datastructures/region.hpp=0A branches= /ld_urbanhafner/src/datastructures/test/=0A branches/ld_urbanhafner/src/= datastructures/test/Makefile.am=0A branches/ld_urbanhafner/src/datastruc= tures/test/region_test.hpp=0A=0AProperty Changed:=0A----------------=0A = branches/ld_urbanhafner/=0A=0A=0AProperty changes on: branches/ld_urbanhafn= er=0A___________________________________________________________________=0A= Name: svn:ignore=0A - crashes=0AkgsGtp*=0Abuild=0Ahousebot.xcodeproj=0Aho= usebot=0Adoxygen_log.txt=0Aaclocal.m4=0Aautom4te.cache=0Agmon.out=0Aprofile= _*.txt=0Aconfig.status=0Aconfig.log=0Aconfigure=0AMakefile=0AMakefile.in=0A= depcomp=0Ainstall-sh=0Amissing=0Amkinstalldirs=0Anohup.out=0A*.sgf=0Akgslog= *=0Astart_housebot=0Abin=0A=0A + Makefile=0AMakefile.in=0Aautom4te.cache= =0Aconfig.guess=0Aconfig.log=0Aconfig.status=0Aconfig.sub=0Aconfigure=0Adep= comp=0Adoxygen_log.txt=0A*.sgf=0Amissing=0Aaclocal.m4=0A=0A=0AModified: bra= nches/ld_urbanhafner/Doxyfile=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=0A--- branches/ld_urbanhafner/Doxyfile 2007-02-09 09:22:17 UTC= (rev 469)=0A+++ branches/ld_urbanhafner/Doxyfile 2007-02-17 16:44:14 UT= C (rev 470)=0A@@ -228,7 +228,7 @@=0A# Private class members and static file= members will be hidden unless =0A# the EXTRACT_PRIVATE and EXTRACT_STATIC = tags are set to YES=0A=0A-EXTRACT_ALL =3D NO=0A+EXTRACT_ALL = =3D YES=0A=0A# If the EXTRACT_PRIVATE tag is set to YES all private = members of a class =0A# will be included in the documentation.=0A@@ -406,7 = +406,7 @@=0A# The QUIET tag can be used to turn on/off the messages that ar= e generated =0A# by doxygen. Possible values are YES and NO. If left blank = NO is used.=0A=0A-QUIET =3D YES=0A+QUIET = =3D NO=0A=0A# The WARNINGS tag can be used to turn on/off the warning messa= ges that are =0A# generated by doxygen. Possible values are YES and NO. If = left blank =0A@@ -556,7 +556,7 @@=0A# Note: To get rid of all source code i= n the generated output, make sure also =0A# VERBATIM_HEADERS is set to NO.= =0A=0A-SOURCE_BROWSER =3D NO=0A+SOURCE_BROWSER =3D YES=0A= =0A# Setting the INLINE_SOURCES tag to YES will include the body =0A# of fu= nctions and classes directly in the documentation.=0A@@ -603,7 +603,7 @@=0A= # of all compounds will be generated. Enable this if the project =0A# conta= ins a lot of classes, structs, unions or interfaces.=0A=0A-ALPHABETICAL_IND= EX =3D NO=0A+ALPHABETICAL_INDEX =3D YES=0A=0A# If the alphabetical = index is enabled (see ALPHABETICAL_INDEX) then =0A# the COLS_IN_ALPHA_INDEX= tag can be used to specify the number of columns =0A=0AModified: branches/= ld_urbanhafner/configure.ac=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=0A--- branches/ld_urbanhafner/configure.ac 2007-02-09 09:22:17 UT= C (rev 469)=0A+++ branches/ld_urbanhafner/configure.ac 2007-02-17 16:44:= 14 UTC (rev 470)=0A@@ -42,6 +42,6 @@=0A=0AAC_SUBST(OPTIONAL_SUBDIRS)=0A=0A-= AC_OUTPUT([Makefile src/Makefile src/brains/Makefile src/sgf/Makefile src/g= tp/Makefile src/pattern/Makefile src/phil/Makefile src/brains/test/Makefile= src/pattern/test/Makefile])=0A+AC_OUTPUT([Makefile src/Makefile src/brains= /Makefile src/sgf/Makefile src/gtp/Makefile src/pattern/Makefile src/phil/M= akefile src/datastructures/Makefile src/brains/test/Makefile src/pattern/te= st/Makefile src/datastructures/test/Makefile])=0A=0A=0A=0AModified: branche= s/ld_urbanhafner/src/Makefile.am=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=0A--- branches/ld_urbanhafner/src/Makefile.am 2007-02-09 09= :22:17 UTC (rev 469)=0A+++ branches/ld_urbanhafner/src/Makefile.am 2007-= 02-17 16:44:14 UTC (rev 470)=0A@@ -4,7 +4,7 @@=0AAM_LDFLAGS =3D $(BOOST_LDF= LAGS) =0ALIBS =3D $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB) $(BOOST_PROGRAM_OPTI= ONS_LIB)=0A=0A-SUBDIRS =3D brains gtp pattern phil sgf=0A+SUBDIRS =3D brain= s gtp pattern phil sgf datastructures=0Abin_PROGRAMS =3D housebot_0_5=0A=0A= # The source files in the current directory=0A@@ -15,10 +15,11 @@=0A# For t= he test framework to work correctly the object files of the test classes=0A= # have to be linked in directly. Using a library doesn't work!=0ACXXTESTS = =3D ./brains/test/static_ld_test.o ./brains/test/fundamental_test.o \=0A- = ./brains/test/regions_test.o ./pattern/test/pattern_test.o=0A+ = ./brains/test/regions_test.o ./pattern/test/pattern_test.o \=0A+ = ./datastructures/test/region_test.o=0A=0ALDADD =3D $(CXXTESTS) ./brains/= libbrains.a ./sgf/libsgf.a ./gtp/libgtp.a \=0A- ./phil/libphil.a ./p= attern/libpattern.a=0A+ ./phil/libphil.a ./pattern/libpattern.a ./da= tastructures/libds.a=0A=0AAM_CPPFLAGS =3D -I../$(CXXTEST) $(HB_CFLAGS)=0A= =0A=0A=0AProperty changes on: branches/ld_urbanhafner/src/datastructures=0A= ___________________________________________________________________=0AName:= svn:ignore=0A + Makefile=0AMakefile.in=0A.deps=0A*.o=0Alibds.a=0A=0A=0AA= dded: branches/ld_urbanhafner/src/datastructures/Makefile.am=0A=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A--- branches/ld_urbanhafner/src/d= atastructures/Makefile.am (rev 0)=0A+++ branches= /ld_urbanhafner/src/datastructures/Makefile.am 2007-02-17 16:44:14 UTC (= rev 470)=0A@@ -0,0 +1,8 @@=0A+ACLOCAL_AMFLAGS =3D -I ../../m4=0A+AM_CXXFLAG= S =3D $(BOOST_CPPFLAGS)=0A+=0A+SUBDIRS =3D test=0A+noinst_LIBRARIES =3D lib= ds.a=0A+libds_a_SOURCES =3D region.cpp region.hpp=0A+=0A+AM_CPPFLAGS =3D -I= .. $(HB_CFLAGS)=0A=0AAdded: branches/ld_urbanhafner/src/datastructures/reg= ion.cpp=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A--- branc= hes/ld_urbanhafner/src/datastructures/region.cpp = (rev 0)=0A+++ branches/ld_urbanhafner/src/datastructures/region.cpp 200= 7-02-17 16:44:14 UTC (rev 470)=0A@@ -0,0 +1,72 @@=0A+/*********************= ************************************************=0A+ * Copyright (C) 2007 = Urban Hafner *=0A+ * = *=0A+ * This file is part of h= ousebot. *=0A+ * = *=0A+ * This program is free sof= tware; you can redistribute it and/or *=0A+ * modify it under the terms= of the GNU General Public License *=0A+ * as published by the Free S= oftware Foundation; either version 2 *=0A+ * of the License, or (at your= option) any later version. *=0A+ * = *=0A+ * This program is distributed i= n the hope that it will be useful, *=0A+ * but WITHOUT ANY WARRANTY; with= out even the implied warranty of *=0A+ * MERCHANTABILITY or FITNESS FOR = A PARTICULAR PURPOSE. See the *=0A+ * GNU General Public License for m= ore details. *=0A+ * = *=0A+ * You should have received a copy of= the GNU General Public License *=0A+ * along with this program; if not, wr= ite to the Free Software *=0A+ * Foundation, Inc., 51 Franklin Street= , Fifth Floor, Boston, *=0A+ * MA 02110-1301, USA. = *=0A+ ****************************************= *****************************/=0A+=0A+#include "datastructures/region.hpp"= =0A+=0A+namespace ds {=0A+=0A+ void region::add_defender_chain(brain::chai= n* ch) {=0A+ defender.insert(ch);=0A+ brain::chain::const_stone_itera= tor i;=0A+ for (i =3D ch->stones_begin(); i !=3D ch->stones_end(); ++i) = {=0A+ add_asa(*i);=0A+ }=0A+ }=0A+=0A+ void region::remove_defend= er_chain(brain::chain* ch) {=0A+ brain::chain::const_stone_iterator i;= =0A+ for (i =3D ch->stones_begin(); i !=3D ch->stones_end(); ++i) {=0A+ = remove_asa(*i);=0A+ }=0A+ defender.erase(ch);=0A+ }=0A+=0A+ vo= id region::add_attacker_chain(brain::chain* ch) {=0A+ attacker.insert(ch= );=0A+ brain::chain::const_stone_iterator i;=0A+ for (i =3D ch->stone= s_begin(); i !=3D ch->stones_end(); ++i) {=0A+ positions.insert(*i);= =0A+ }=0A+ }=0A+ =0A+ void region::remove_attacker_chain(brain::chain= * ch) {=0A+ attacker.erase(ch);=0A+ brain::chain::const_stone_iterato= r i;=0A+ for (i =3D ch->stones_begin(); i !=3D ch->stones_end(); ++i) {= =0A+ positions.erase(*i);=0A+ } =0A+ }=0A+ =0A+ void region::= merge(const region &r) {=0A+ HBASSERT(col =3D=3D r.color());=0A+ libe= rties.insert(r.accessible_liberties_begin(),=0A+ r.acce= ssible_liberties_end());=0A+ asas.insert(r.asa_begin(), r.asa_end());=0A= + enclosing.insert(r.enclosing_chains_begin(),=0A+ r= .enclosing_chains_end());=0A+ defender.insert(r.defender_chains_begin(),= =0A+ r.defender_chains_end());=0A+ attacker.insert(r.= attacker_chains_begin(),=0A+ r.attacker_chains_end());= =0A+ positions.insert(r.positions_begin(), r.positions_end());=0A+ }=0A= + =0A+} /* ds */=0A\ No newline at end of file=0A=0AAdded: branches/ld_urb= anhafner/src/datastructures/region.hpp=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=0A--- branches/ld_urbanhafner/src/datastructures/region.= hpp (rev 0)=0A+++ branches/ld_urbanhafner/src/da= tastructures/region.hpp 2007-02-17 16:44:14 UTC (rev 470)=0A@@ -0,0 +1,1= 45 @@=0A+/*****************************************************************= ****=0A+ * Copyright (C) 2007 Urban Hafner = *=0A+ * = *=0A+ * This file is part of housebot. = *=0A+ * *= =0A+ * This program is free software; you can redistribute it and/or *= =0A+ * modify it under the terms of the GNU General Public License *= =0A+ * as published by the Free Software Foundation; either version 2 *= =0A+ * of the License, or (at your option) any later version. *= =0A+ * *= =0A+ * This program is distributed in the hope that it will be useful, *= =0A+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *= =0A+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *= =0A+ * GNU General Public License for more details. *= =0A+ * *= =0A+ * You should have received a copy of the GNU General Public License *= =0A+ * along with this program; if not, write to the Free Software *= =0A+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *= =0A+ * MA 02110-1301, USA. *= =0A+ *********************************************************************/= =0A+=0A+#ifndef _REGION_HPP_=0A+#define _REGION_HPP_=0A+=0A+#include "brain= s/chains.hpp"=0A+#include "util.hpp"=0A+=0A+namespace ds {=0A+ =0A+ /// \= brief Represents a region in the Muellerian sense.=0A+ ///=0A+ /// A regi= on represents a connected group of positions on the board.=0A+ /// These p= ositions are surrounded by chains of color c (called=0A+ /// enclosing cha= ins) and may contain both chains of color c (called=0A+ /// defender chain= s) and chains of the opponent (called attacker=0A+ /// chains). The positi= ons that are liberties of the enclosing chains=0A+ /// are called accessib= le liberties and interior positions that are=0A+ /// not occupied by the a= ttacker are called attacker's surroundable=0A+ /// area (or ASA for short)= .=0A+ class region {=0A+ color_t col;=0A+ std::set<position> liberti= es;=0A+ std::set<position> asas;=0A+ std::set<position> positions;=0A= + std::set<brain::chain*> enclosing;=0A+ std::set<brain::chain*> atta= cker;=0A+ std::set<brain::chain*> defender;=0A+ =0A+ public:=0A+ = /// Iterator type for the accessible liberties.=0A+ typedef std::set<pos= ition>::const_iterator const_liberty_iterator;=0A+ /// Iterator type for= the attacker's surroundable area.=0A+ typedef std::set<position>::const= _iterator const_area_iterator;=0A+ /// Iterator for the various enumerat= ions of chains.=0A+ typedef std::set<brain::chain*>::const_iterator co= nst_chain_iterator;=0A+ =0A+ /// Create a new region of color c.=0A+ = region(color_t c):col(c) {}=0A+ =0A+ /// The number of accessible = liberties of the surrounding chains.=0A+ int accessible_liberties() cons= t { return liberties.size(); }=0A+ const_liberty_iterator accessible_lib= erties_begin() const {=0A+ return liberties.begin();=0A+ }=0A+ c= onst_liberty_iterator accessible_liberties_end() const {=0A+ return li= berties.end();=0A+ }=0A+ void add_liberty(const position &p) {=0A+ = liberties.insert(p);=0A+ positions.insert(p);=0A+ }=0A+ void = remove_liberty(const position &p) {=0A+ liberties.erase(p);=0A+ p= ositions.erase(p);=0A+ }=0A+ =0A+ /// The number of attacker's sur= roundable area positions.=0A+ int asa() const { return asas.size(); }=0A= + const_area_iterator asa_begin() const { return asas.begin(); }=0A+ = const_area_iterator asa_end() const { return asas.end(); }=0A+ void add_= asa(const position &p) {=0A+ asas.insert(p);=0A+ positions.insert= (p);=0A+ }=0A+ void remove_asa(const position &p) {=0A+ asas.era= se(p);=0A+ positions.erase(p);=0A+ }=0A+ =0A+ /// The number = of enclosing chains.=0A+ int enclosing_chains() const { return enclosing= .size(); }=0A+ const_chain_iterator enclosing_chains_begin() const {=0A+= return enclosing.begin();=0A+ }=0A+ const_chain_iterator enclos= ing_chains_end() const {=0A+ return enclosing.end();=0A+ }=0A+ v= oid add_enclosing_chain(brain::chain* ch) { enclosing.insert(ch); }=0A+ = void remove_enclosing_chain(brain::chain* ch) { enclosing.erase(ch); }=0A+ = =0A+ /// The number of defender chains.=0A+ int defender_chains() = const { return defender.size(); }=0A+ const_chain_iterator defender_chai= ns_begin() const {=0A+ return defender.begin();=0A+ }=0A+ const_= chain_iterator defender_chains_end() const {=0A+ return defender.end()= ;=0A+ }=0A+ /// Add chain to the defender chains and all positions to= the=0A+ /// attacker's surroundable area.=0A+ void add_defender_chai= n(brain::chain* ch);=0A+ void remove_defender_chain(brain::chain* ch);= =0A+ =0A+ /// The number of attacker chains.=0A+ int attacker_chai= ns() const { return attacker.size(); }=0A+ const_chain_iterator attacker= _chains_begin() const {=0A+ return attacker.begin();=0A+ }=0A+ c= onst_chain_iterator attacker_chains_end() const {=0A+ return attacker.= end();=0A+ }=0A+ void add_attacker_chain(brain::chain* ch);=0A+ vo= id remove_attacker_chain(brain::chain* ch);=0A+ =0A+ int size() const= { return positions.size(); }=0A+ const_area_iterator positions_begin() = const {=0A+ return positions.begin();=0A+ }=0A+ const_area_itera= tor positions_end() const {=0A+ return positions.end();=0A+ }=0A+ = const_area_iterator find_position(const position &p) const {=0A+ ret= urn positions.find(p);=0A+ }=0A+ =0A+ color_t color() const { retu= rn col;}=0A+ position id() const {return *positions.begin();}=0A+ =0A= + /// Merges r into the region. It doesn't check whether some chains=0A+= /// or points appear in several categories.=0A+ void merge(const reg= ion &r);=0A+ };=0A+} /* ds */=0A+=0A+#endif /* _REGION_HPP_ */=0A\ No newl= ine at end of file=0A=0A=0AProperty changes on: branches/ld_urbanhafner/src= /datastructures/test=0A____________________________________________________= _______________=0AName: svn:ignore=0A + Makefile=0AMakefile.in=0A.deps=0A= *.cpp=0Alibds_test.a=0A=0A=0AAdded: branches/ld_urbanhafner/src/datastructu= res/test/Makefile.am=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =0A--- branches/ld_urbanhafner/src/datastructures/test/Makefile.am = (rev 0)=0A+++ branches/ld_urbanhafner/src/datastructures= /test/Makefile.am 2007-02-17 16:44:14 UTC (rev 470)=0A@@ -0,0 +1,12 @@= =0A+ACLOCAL_AMFLAGS =3D -I ../../../m4=0A+AM_CXXFLAGS =3D $(BOOST_CPPFLAGS)= =0A+=0A+noinst_LIBRARIES =3D libds_test.a=0A+libds_test_a_SOURCES =3D regio= n_test.cpp=0A+=0A+AM_CPPFLAGS =3D -I.. -I../.. -I../../../$(CXXTEST) $(HB_C= FLAGS)=0A+=0A+clean:=0A+ $(RM) *.cpp *.o libds_test.a=0A+.hpp.cpp:=0A+ = $(PERL) ../../../$(CXXTESTGEN) $(CXXTESTGEN_OPTS) -o $@ $^=0A=0AAdded: br= anches/ld_urbanhafner/src/datastructures/test/region_test.hpp=0A=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A--- branches/ld_urbanhafner/sr= c/datastructures/test/region_test.hpp (rev 0)=0A= +++ branches/ld_urbanhafner/src/datastructures/test/region_test.hpp 2007= -02-17 16:44:14 UTC (rev 470)=0A@@ -0,0 +1,182 @@=0A+/*********************= ************************************************=0A+ * Copyright (C) 2007 = Urban Hafner *=0A+ * = *=0A+ * This file is part of h= ousebot. *=0A+ * = *=0A+ * This program is free sof= tware; you can redistribute it and/or *=0A+ * modify it under the terms= of the GNU General Public License *=0A+ * as published by the Free S= oftware Foundation; either version 2 *=0A+ * of the License, or (at your= option) any later version. *=0A+ * = *=0A+ * This program is distributed i= n the hope that it will be useful, *=0A+ * but WITHOUT ANY WARRANTY; with= out even the implied warranty of *=0A+ * MERCHANTABILITY or FITNESS FOR = A PARTICULAR PURPOSE. See the *=0A+ * GNU General Public License for m= ore details. *=0A+ * = *=0A+ * You should have received a copy of= the GNU General Public License *=0A+ * along with this program; if not, wr= ite to the Free Software *=0A+ * Foundation, Inc., 51 Franklin Street= , Fifth Floor, Boston, *=0A+ * MA 02110-1301, USA. = *=0A+ ****************************************= *****************************/=0A+=0A+#ifndef _REGION_TEST_HPP_=0A+#define = _REGION_TEST_HPP_=0A+=0A+#include <cxxtest/TestSuite.h>=0A+#include "datast= ructures/region.hpp"=0A+=0A+class region_test: public CxxTest::TestSuite {= =0A+public:=0A+ ds::region *r1;=0A+ ds::region *r2;=0A+ brain::chain *ch= 1;=0A+ brain::chain *ch2;=0A+ brain::chain *ch3;=0A+ =0A+ void setUp() = {=0A+ r1 =3D new ds::region(black);=0A+ r2 =3D new ds::region(black);= =0A+ ch1 =3D new brain::chain(9);=0A+ ch1->add_member(position(0,0));= =0A+ ch2 =3D new brain::chain(9);=0A+ ch2->add_member(position(2,2));= =0A+ ch3 =3D new brain::chain(9);=0A+ ch3->add_member(position(3,3));= =0A+ }=0A+ =0A+ void tearDown() {=0A+ delete ch3;=0A+ delete ch2;= =0A+ delete ch1;=0A+ delete r2;=0A+ delete r1;=0A+ }=0A+ =0A+ v= oid test_empty_region() {=0A+ TS_ASSERT_EQUALS(r1->size(), 0);=0A+ TS= _ASSERT_EQUALS(r1->accessible_liberties(), 0);=0A+ TS_ASSERT_EQUALS(r1->= asa(), 0);=0A+ TS_ASSERT_EQUALS(r1->defender_chains(), 0);=0A+ TS_ASS= ERT_EQUALS(r1->attacker_chains(), 0);=0A+ TS_ASSERT_EQUALS(r1->enclosing= _chains(), 0);=0A+ }=0A+ =0A+ void test_liberties() {=0A+ r1->add_lib= erty(position(0,0));=0A+ TS_ASSERT_EQUALS(r1->size(), 1);=0A+ TS_ASSE= RT_EQUALS(r1->accessible_liberties(), 1);=0A+ TS_ASSERT_EQUALS(r1->asa()= , 0);=0A+ TS_ASSERT_EQUALS(r1->defender_chains(), 0);=0A+ TS_ASSERT_E= QUALS(r1->attacker_chains(), 0);=0A+ TS_ASSERT_EQUALS(r1->enclosing_chai= ns(), 0);=0A+ r1->remove_liberty(position(0,0));=0A+ TS_ASSERT_EQUALS= (r1->size(), 0);=0A+ TS_ASSERT_EQUALS(r1->accessible_liberties(), 0);=0A= + TS_ASSERT_EQUALS(r1->asa(), 0);=0A+ TS_ASSERT_EQUALS(r1->defender_c= hains(), 0);=0A+ TS_ASSERT_EQUALS(r1->attacker_chains(), 0);=0A+ TS_A= SSERT_EQUALS(r1->enclosing_chains(), 0); =0A+ }=0A+ =0A+ void test_as= a() {=0A+ r1->add_asa(position(0,0));=0A+ TS_ASSERT_EQUALS(r1->size()= , 1);=0A+ TS_ASSERT_EQUALS(r1->accessible_liberties(), 0);=0A+ TS_ASS= ERT_EQUALS(r1->asa(), 1);=0A+ TS_ASSERT_EQUALS(r1->defender_chains(), 0)= ;=0A+ TS_ASSERT_EQUALS(r1->attacker_chains(), 0);=0A+ TS_ASSERT_EQUAL= S(r1->enclosing_chains(), 0); =0A+ r1->remove_asa(position(0,0));=0A+= TS_ASSERT_EQUALS(r1->size(), 0);=0A+ TS_ASSERT_EQUALS(r1->accessible= _liberties(), 0);=0A+ TS_ASSERT_EQUALS(r1->asa(), 0);=0A+ TS_ASSERT_E= QUALS(r1->defender_chains(), 0);=0A+ TS_ASSERT_EQUALS(r1->attacker_chain= s(), 0);=0A+ TS_ASSERT_EQUALS(r1->enclosing_chains(), 0);=0A+ }=0A+ = =0A+ void test_defender_chains() {=0A+ TS_ASSERT_EQUALS(ch1->size(), 1)= ;=0A+ r1->add_defender_chain(ch1);=0A+ TS_ASSERT_EQUALS(r1->size(), 1= );=0A+ TS_ASSERT_EQUALS(r1->accessible_liberties(), 0);=0A+ TS_ASSERT= _EQUALS(r1->asa(), 1);=0A+ TS_ASSERT_EQUALS(r1->defender_chains(), 1);= =0A+ TS_ASSERT_EQUALS(r1->attacker_chains(), 0);=0A+ TS_ASSERT_EQUALS= (r1->enclosing_chains(), 0);=0A+ r1->remove_defender_chain(ch1);=0A+ = TS_ASSERT_EQUALS(r1->size(), 0);=0A+ TS_ASSERT_EQUALS(r1->accessible_lib= erties(), 0);=0A+ TS_ASSERT_EQUALS(r1->asa(), 0);=0A+ TS_ASSERT_EQUAL= S(r1->defender_chains(), 0);=0A+ TS_ASSERT_EQUALS(r1->attacker_chains(),= 0);=0A+ TS_ASSERT_EQUALS(r1->enclosing_chains(), 0);=0A+ }=0A+ =0A+ = void test_attacker_chains() {=0A+ TS_ASSERT_EQUALS(ch1->size(), 1);=0A+ = r1->add_attacker_chain(ch1);=0A+ TS_ASSERT_EQUALS(r1->size(), 1);=0A+= TS_ASSERT_EQUALS(r1->accessible_liberties(), 0);=0A+ TS_ASSERT_EQUAL= S(r1->asa(), 0);=0A+ TS_ASSERT_EQUALS(r1->defender_chains(), 0);=0A+ = TS_ASSERT_EQUALS(r1->attacker_chains(), 1);=0A+ TS_ASSERT_EQUALS(r1->enc= losing_chains(), 0);=0A+ r1->remove_attacker_chain(ch1);=0A+ TS_ASSER= T_EQUALS(r1->size(), 0);=0A+ TS_ASSERT_EQUALS(r1->accessible_liberties()= , 0);=0A+ TS_ASSERT_EQUALS(r1->asa(), 0);=0A+ TS_ASSERT_EQUALS(r1->de= fender_chains(), 0);=0A+ TS_ASSERT_EQUALS(r1->attacker_chains(), 0);=0A+= TS_ASSERT_EQUALS(r1->enclosing_chains(), 0);=0A+ }=0A+ =0A+ void tes= t_enclosing_chains() {=0A+ TS_ASSERT_EQUALS(ch1->size(), 1);=0A+ r1->= add_enclosing_chain(ch1);=0A+ TS_ASSERT_EQUALS(r1->size(), 0);=0A+ TS= _ASSERT_EQUALS(r1->accessible_liberties(), 0);=0A+ TS_ASSERT_EQUALS(r1->= asa(), 0);=0A+ TS_ASSERT_EQUALS(r1->defender_chains(), 0);=0A+ TS_ASS= ERT_EQUALS(r1->attacker_chains(), 0);=0A+ TS_ASSERT_EQUALS(r1->enclosing= _chains(), 1);=0A+ r1->remove_enclosing_chain(ch1);=0A+ TS_ASSERT_EQU= ALS(r1->size(), 0);=0A+ TS_ASSERT_EQUALS(r1->accessible_liberties(), 0);= =0A+ TS_ASSERT_EQUALS(r1->asa(), 0);=0A+ TS_ASSERT_EQUALS(r1->defende= r_chains(), 0);=0A+ TS_ASSERT_EQUALS(r1->attacker_chains(), 0);=0A+ T= S_ASSERT_EQUALS(r1->enclosing_chains(), 0);=0A+ }=0A+ =0A+ void test_mer= ge() {=0A+ r1->add_liberty(position(1,1));=0A+ r1->add_liberty(positi= on(2,1));=0A+ r1->add_defender_chain(ch2);=0A+ TS_ASSERT_EQUALS(r1->s= ize(), 3);=0A+ TS_ASSERT_EQUALS(r1->accessible_liberties(), 2);=0A+ T= S_ASSERT_EQUALS(r1->asa(), 1);=0A+ TS_ASSERT_EQUALS(r1->defender_chains(= ), 1);=0A+ TS_ASSERT_EQUALS(r1->attacker_chains(), 0);=0A+ TS_ASSERT_= EQUALS(r1->enclosing_chains(), 0);=0A+ r2->add_liberty(position(1,1));= =0A+ r2->add_liberty(position(1,2));=0A+ r2->add_attacker_chain(ch1);= =0A+ r2->add_enclosing_chain(ch3);=0A+ TS_ASSERT_EQUALS(r2->size(), 3= );=0A+ TS_ASSERT_EQUALS(r2->accessible_liberties(), 2);=0A+ TS_ASSERT= _EQUALS(r2->asa(), 0);=0A+ TS_ASSERT_EQUALS(r2->defender_chains(), 0);= =0A+ TS_ASSERT_EQUALS(r2->attacker_chains(), 1);=0A+ TS_ASSERT_EQUALS= (r2->enclosing_chains(), 1);=0A+ r1->merge(*r2);=0A+ TS_ASSERT_EQUALS= (r1->size(), 5);=0A+ TS_ASSERT_EQUALS(r1->accessible_liberties(), 3);=0A= + TS_ASSERT_EQUALS(r1->asa(), 1);=0A+ TS_ASSERT_EQUALS(r1->defender_c= hains(), 1);=0A+ TS_ASSERT_EQUALS(r1->attacker_chains(), 1);=0A+ TS_A= SSERT_EQUALS(r1->enclosing_chains(), 1);=0A+ }=0A+};=0A+=0A+#endif /* _REG= ION_TEST_HPP_ */=0A=0A=0AThis was sent by the SourceForge.net collaborative= development platform, the world's largest Open Source development site.=0A= =0A------------------------------------------------------------------------= -=0ATake Surveys. Earn Cash. Influence the Future of IT=0AJoin SourceForge.= net's Techsay panel and you'll get the chance to share your=0Aopinions on I= T & business topics through brief surveys-and earn cash=0Ahttp://www.techsa= y.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A__________= _____________________________________=0AHousebot-developers mailing list=0A= Hou...@li...=0Ahttps://lists.sourceforge.net/l= ists/listinfo/housebot-developers |