![]() StartingPoints Referenced by
|
The Code So Far - 2
I decide to write a simple move chooser. The initial algorithm is extremely naive: for each connected string of stones, assign an urgency based on the number of liberties that it has. For all empty spaces, add up the urgencies of all adjacent strings. Pick the space with the highest score. Note that it has no concept of kill versus save or even who the current player is. (defun urgency (liberties-length) (case liberties-length ((1) 50) ((2) 10) ((3) 3) (otherwise 1))) (defmethod get-candidate-moves-0 ((analyzer analyzer)) (let ((worm-info (worm-info (game analyzer))) (game-board (game-board (game analyzer)))) (let ((candidates (mapcan (lambda (worm) (let ((liberties (liberties worm game-board))) (mapcar (lambda (point) (cons point (urgency (length liberties)))) liberties))) (snakes worm-info)))) (collapse candidates #'+))))
The right hand side move a is good if white plays, unfortunately, the problem is for black to play and kill. Problem 1-23 is the first problem in the book for which the correct move is different depending on who is to play.
I add the victory condition code back in - the program now knows it has solved the first 14 problems, 15 is "to save" and it has no criterion by which to judge success. For now, I'll just add the "more than 3 liberties is safe" rule. Maybe I should implement a series of analyzers, varying from fast and simple to slow and careful? Unresolved boards could start with simple analyzers and retry with the more complex ones as game time permits? This is a copy of the living page "The Code So Far - 2" at Sensei's Library. (C) the Authors, published under the OpenContent License V1.0. |