anchor.diff:              (push piece (gethash key result nil))))
       result))
   
  +(declaim (inline satisfy-req))
  +(defun satisfy-req (req-sig final-sig)
  +  (not (loop 
  +          for req-point in req-sig
  +          for final-point in final-sig
  +          when (< final-point req-point)
  +          return t)))
  +
  +(defun filter-arsenal-with-jewels (required-effects preliminary-arsenal)
  +  (let ((jewel-combos (create-jewel-combos required-effects))
  +        (result nil)
  +        (req-sig (mapcar #`,(cadr x1) required-effects))
  +        (req-size (length required-effects)))
  +    (format t "filtering started ...~%")
  +    (format t "preliminary: ~a~%" (hash-table-count preliminary-arsenal))
  +    (loop 
  +       for armor-key being the hash-keys of preliminary-arsenal
  +       for tree being the hash-values of preliminary-arsenal
  +       do (awhen (loop for item in 
  +                      (gethash (the (signed-byte 64) (hole-part armor-key))
  +                               jewel-combos)
  +                    when (satisfy-req req-sig 
  +                                      (decode-skill-sig-full
  +                                       (encoded-+ armor-key
  +                                                  (jewel-combo-key (car item)))
  +                                       req-size))
  +                    collect item)
  +            (push (make-armor-preliminary :tree tree
  +                                          :jewel-sets it)
  +                  result)))
  +    result))
  +
   (defun search-core (required-effects)
     (let* ((arsenal (list *helms* *cuirasses*
                           *gloves* *cuisses*
                           *sabatons*))
            (clustered-arsenal (mapcar #`,(cluster-armors x1
                                                          required-effects)
  -                                    arsenal)))
  -    (reduce (lambda (merged current-part)
  -              (let ((new-merged (make-map)))
  -                (loop 
  -                   for current-key being the hash-keys of current-part
  -                   for current-item being the hash-values of current-part
  -                   do (loop 
  -                         for merged-key being the hash-keys of merged
  -                         for merged-item being the hash-values of merged
  -                         do (let ((new-key (encoded-+ current-key
  -                                                      merged-key)))
  -                              (declare (type (unsigned-byte 64) new-key))
  -                              (push (make-armor-tree :left current-item
  -                                                     :right merged-item)
  -                                    (gethash new-key new-merged nil)))))
  -                new-merged))
  -            clustered-arsenal)))
  -
  -
  -                                  
  -              
  -  
  -  
  -
  -
  -
  -
  -
  -
  -
  -  
  -
  -  
  -                                                  
  -                                
  -                   
  -  
  -  
  -  
  -    
  -
  -
  +                                    arsenal))
  +         ;; Construct the armor tree (without jewels)
  +         (preliminary-arsenal
  +          (reduce (lambda (merged current-part)
  +                    (let ((new-merged (make-map)))
  +                      (loop 
  +                         for current-key being the hash-keys of current-part
  +                         for current-item being the hash-values of current-part
  +                         do (loop 
  +                               for merged-key being the hash-keys of merged
  +                               for merged-item being the hash-values of merged
  +                               do (let ((new-key (encoded-+ current-key
  +                                                            merged-key)))
  +                                    (declare (type (unsigned-byte 64) new-key))
  +                                    (push (make-armor-tree :left current-item
  +                                                           :right merged-item)
  +                                          (gethash new-key new-merged nil)))))
  +                      new-merged))
  +                  clustered-arsenal)))
  +    ;; Filter out the buckets that cannot meet requirement with jewels
  +    (filter-arsenal-with-jewels required-effects preliminary-arsenal)))
  +
  +
  +;;; ---------- Debug Utility ----------
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  
positive.code:                         :initial-contents elements))
        (format t "[ok] Jewels loaded.~%")
        nil)))
           
    
  
  ;;; ---------- Initialization ----------
  
  
negative.code:          do (push combos (gethash (hole-part key)
                                    hole-map nil)))
        hole-map)))
  
  
  ;;; ---------- Search ----------
  