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

RE: [computer-go] Re: Sharing Secrets



The secret of Many Faces of Go is that I have no code "that does it right".
All my code
does it "good enough".  Striving to "do it right" leads to never finishing a
go program.

I use Zobrist hashing of course, but I've never tried to optimize the random
number hashing
distance, or even tried to calculate the probability of collision.  Hash
collisions have
never limited the strength of the program.  My point is that you should work
on whatever
part of the program leads to loses against human opponents, and never try to
get
exact evaluations of anything unless it causes games to be lost. 

Here is a typial piece of code, to evaluate the connectivity of a large
knight move.  It
does always get the right answer, but it is good enough.  It's unlikely that
anyone
else will be able to see what I'm doing without a lot of other
documentation, since I
like to use short names to save typing.

David

/* evaluate large knight connection between g and g2.  s and s2 are the
linkage
 * points.  (s is upper).  dir is direction from s to s2. g and g2 may be
reversed.
 *
 *   s  +   sn  g2    dir ->
 *   g  sn2 +   s2
 *
 */

static int largeknight(group_t g, group_t g2, int c, conn_t cn, sqr_t s,
sqr_t s2, int dir, listval_t ldrno){
	int on_edge;
	sqr_t sn,sn2;

	cn = cn;
	on_edge = edge[s] <= 4 && edge[s2] <= 4 && edge[s] != edge[s2];
	if(on_edge){
		if(edge[s2] < edge[s] && 
			(lnbf[s2][1-c] || lnbf[s2-dir][1-c]) ||
			edge[s] < edge[s2] &&
			(lnbf[s][1-c] || lnbf[s+dir][1-c]))
			on_edge = FALSE;  /* enemy stone between connection
and edge */
		}
		
	sn = s + dir + dir;
	sn2 = s2-dir-dir;
#ifdef CNPATH
	addlist(sn, &cnpathptr[cn]);
	addlist(sn2, &cnpathptr[cn]);
	addlist((listval_t)(s+dir), &cnpathptr[cn]);
	addlist((listval_t)(s2-dir), &cnpathptr[cn]);
#endif
	addldrflag(s,ldrno);
	addldrflag(s2,ldrno);
	addldrflag(sn,ldrno);
	addldrflag(sn2,ldrno);
	if(edge[s] == 1 && edge[s2] == 2 ||
	   edge[s] == 2 && edge[s2] == 1){  /* monkey jump */
		if(grlibs[g] >= 3 && grlibs[g2] >= 3 &&
			!G_THREATENED(g) && !G_THREATENED(g2))
			return(AJI_CONNECT);
		else
			return(CAN_CONNECT);
		}
	if(G_THREATENED(g) || G_THREATENED(g2))return(CANT_CONNECT);
	if((ld[s] >= 4 && !S_NEUTRAL(sn2) ||
		ld[s2] >= 4 && !S_NEUTRAL(sn)) &&
		grlibs[g] > 2 && grlibs[g2] > 2 &&
		(grlibs[g] >= 4 || grlibs[g2] >= 4)){
		if(on_edge && lnbf[s+dir][1-c] == 0 && lnbf[sn2+dir][1-c] ==
0)
			return(AJI_CONNECT);
		return(CAN_CONNECT);
		}
	if(lnbf[sn][1-c] != 0 && lnbf[sn2][1-c] != 0)
		return(CANT_CONNECT);
	if(grlibs[g] >= 4 && grlibs[g2] >= 4 && 
		lnbf[s+dir][1-c] == 0 && lnbf[sn2+dir][1-c] == 0 &&
		(on_edge || ld[s] > 3 || ld[s2] > 3 || lnbf[sn][c] > 1 &&
!S_NEUTRAL(s) ||
	   lnbf[sn2][c] > 1 && !S_NEUTRAL(s2)))return(AJI_CONNECT);
	return(CAN_CONNECT);
	}



> -----Original Message-----
> From: computer-go-bounces@xxxxxxxxxxxxxxxxx 
> [mailto:computer-go-bounces@xxxxxxxxxxxxxxxxx] On Behalf Of Dave Dyer
> Sent: Thursday, October 21, 2004 10:59 AM
> To: computer-go; computer-go
> Subject: [computer-go] Re: Sharing Secrets
> 
> 
> 
> Sharing all the secrets of best practice is an excellent 
> topic for a long and boring paper.  If you really want to 
> share something worthwhile with your peers, share a piece of 
> code that does it right.
> 
> _______________________________________________
> computer-go mailing list
> computer-go@xxxxxxxxxxxxxxxxx 
> http://www.computer-go.org/mailman/listinfo/computer-go/
> 

_______________________________________________
computer-go mailing list
computer-go@xxxxxxxxxxxxxxxxx
http://www.computer-go.org/mailman/listinfo/computer-go/