![]() StartingPoints Sub-pages (up) Referenced by
|
The Code So Far/Ladder 2
Sub-page of TheCodeSoFar
A slightly easier version of the second spiral ladder in Lessons in the Fundamentals of Go. This problem required a little tweak to my liberties code: the defender can also grab a stone in Atari. This was actually also needed to solve Ladder 1, in that certain variations had "attacks" with the attacking stone in Atari. The inefficient, but adequate, code: (defmethod get-focus-liberties ((analyzer ladder-analyzer)) (let ((game-board (game-board analyzer))) (if (eq (action (goal analyzer)) 'KillG) (liberties (at (smap (game analyzer)) (car (focus analyzer))) game-board) (if (eq (action (goal analyzer)) 'SaveG) (let* ((adj-worms (adjacent-worms (worm-info (game analyzer)) (car (focus analyzer)))) (stressed-worms (remove-if-not (lambda (worm) (eq 1 (length (liberties worm game-board)))) adj-worms)) (fight-points (apply #'append (mapcar (lambda (worm) (liberties worm game-board)) stressed-worms))) (liberties (liberties (at (smap (game analyzer)) (car (focus analyzer))) game-board))) (s-uniq (append fight-points liberties))) ()))))
This is a copy of the living page "The Code So Far/Ladder 2" at Sensei's Library. ![]() |