[Welcome to Sensei's Library!]

StartingPoints
ReferenceSection
About


Referenced by
TheCodeSoFar
TheCodeSoFar2
MetaDiscussion2002

 

Gorobei - The Current Code
   

[(Is there someplace to send comments on the code? I looked for an email address without success. So I'll just stuff my comment in here and hope that someone more knowledgeable can send it where it belongs.)

The LESSP operation

 (defmethod lessp ((p1 Point) (p2 Point))
   (or (< (row p1) (row p2)) (< (col p1) (col p2))))

doesn't "consistently represent a total order" on points (as required by the ANSI specification for SORT). Consider point1=c1 and point2=a3. Then (LESSP point1 point2) and (LESSP point2 point1) are both true! So if you try to use LESSP as the ordering predicate for the ANSI CL SORT function, you'll probably get some bogus result.

There are several ways to make LESSP better behaved, so that when (LESSP a b) you never have (LESSP b a) also. One way is to define a unique one-dimensional index e.g.

  (defun point-index (point)
    (+ (row p1) (* (col p1) board-edge)))

and then define LESSP as

  (defmethod lessp ((p1 point) (p2 point))
     (< (point-index p1) (point-index p2)))

-- Bill Newman (another Lisp Go programmer:-) 2002-03-25]

Gorobei: Ouch! You are quite right - that accounts for some quirky profiling results I was seeing. I wish I could claim that horrible function was due to my just learning LISP, but it is obviously just a stupidity.

I purposely didn't add my email address because I felt that comments such as yours are better contributed to the page... I'd like to show my errors (of design, understanding, and implementation,) as much as any successes I happen to have.


This is the up-to-date version of my Go playing program (it currently can only solve simple Life and Death problems.) You can use SL's page info & history feature (at the bottom of the page) to see the code as it was at the time I wrote something on one of my "The code so far" pages.

Here is a board indicative of the current code's level of play:

[Diagram]
Diag.: Black to save the marked stones.


[Diagram]
Diag.: 1-43: Solution


I've moved the current snapshot to a tarball: [ext] http://members.bellatlantic.net/~mmn/go/go.tar.gz



This is a copy of the living page "Gorobei - The Current Code" at Sensei's Library.
(OC) 2003 the Authors, published under the OpenContent License V1.0.