LOOP is beautiful
From: Jim Bushnell (jcbushnell2_at_comcast.net)
Date: 04/23/04
- Next message: Marc Spitzer: "Re: Two unrelated remarks"
- Previous message: SysAdmin_at_vs.shawcable.net: "IMPORTANT ANTI VIRUS INFORMATION"
- Next in thread: Gareth McCaughan: "Re: LOOP is beautiful"
- Reply: Gareth McCaughan: "Re: LOOP is beautiful"
- Reply: Joe Marshall: "Re: LOOP is beautiful"
- Reply: Marco Antoniotti: "Re: LOOP is beautiful"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Apr 2004 17:34:14 -0600
The following is an implementation of zero-window search (alpha-beta pruning
with a minimal window) for searching trees with integer leaves, and a driver
function for finding the minimax value. I admit to a number of false starts
before I got the logic right, but I attribute this to my obtuseness.
I think this qualifies as beautiful.
(defun zw (tree max alpha)
(if (numberp tree)
(eq max (>= tree alpha))
(loop for child in tree
thereis (not (zw child (not max) alpha)))))
(defun mtdf-zw (tree max guess)
(if (eq max (zw tree max guess))
(loop for v from (1+ guess)
while (eq max (zw tree max v))
finally return (1- v))
(loop for v downfrom (1- guess)
until (eq max (zw tree max v))
finally return v)))
Jim Bushnell
- Next message: Marc Spitzer: "Re: Two unrelated remarks"
- Previous message: SysAdmin_at_vs.shawcable.net: "IMPORTANT ANTI VIRUS INFORMATION"
- Next in thread: Gareth McCaughan: "Re: LOOP is beautiful"
- Reply: Gareth McCaughan: "Re: LOOP is beautiful"
- Reply: Joe Marshall: "Re: LOOP is beautiful"
- Reply: Marco Antoniotti: "Re: LOOP is beautiful"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]