diff org/types.org @ 17:0f6ace87343a

minor typographical changes.
author Robert McIntyre <rlm@mit.edu>
date Mon, 06 Aug 2012 17:26:48 -0400
parents 7698e9bdff2b
children 8992278bf399
line wrap: on
line diff
     1.1 --- a/org/types.org	Mon Aug 06 17:22:39 2012 -0400
     1.2 +++ b/org/types.org	Mon Aug 06 17:26:48 2012 -0400
     1.3 @@ -153,7 +153,8 @@
     1.4  (def pokemon-gen-one pokemon-table-gen-one)
     1.5  (def pokemon-gen-two pokemon-table-gen-two)
     1.6  
     1.7 -(defn type-names [] (vec (doall (map (comp keyword first) pokemon-gen-two))))
     1.8 +(defn type-names [] 
     1.9 +  (vec (doall (map (comp keyword first) pokemon-gen-two))))
    1.10  
    1.11  (defn attack-strengths []
    1.12       (zipmap
    1.13 @@ -322,9 +323,10 @@
    1.14  (in-ns 'pokemon.types)
    1.15  
    1.16  (defn comparatize
    1.17 -  "Define a comparator which uses the numerical outputs of fn as its criterion.
    1.18 -   Objects are sorted in increasing numerical order. Objects with the same fn-value
    1.19 -   are further compared by clojure.core/compare."
    1.20 +  "Define a comparator which uses the numerical outputs of
    1.21 +   fn as its criterion.  Objects are sorted in increasing
    1.22 +   numerical order. Objects with the same fn-value are
    1.23 +   further compared by clojure.core/compare."
    1.24    [fun]
    1.25    (fn [a b]
    1.26      (let [val-a (fun a)
    1.27 @@ -359,12 +361,13 @@
    1.28  
    1.29  (defn best-first-search
    1.30    "Searches through a network of alternatives, pursuing
    1.31 -initially-promising positions first. Comparator defines which
    1.32 -positions are more promising, successors produces a list of improved
    1.33 -positions from the given position (if any exist), and initial-nodes is
    1.34 -a list of starting positions.  Returns a lazy sequence of search results
    1.35 - [visited-nodes unvisited-nodes], which terminates when 
    1.36 -there are no remaining unvisited positions."
    1.37 +   initially-promising positions first. Comparator defines
    1.38 +   which positions are more promising, successors produces a
    1.39 +   list of improved positions from the given position (if
    1.40 +   any exist), and initial-nodes is a list of starting
    1.41 +   positions.  Returns a lazy sequence of search results
    1.42 +   [visited-nodes unvisited-nodes], which terminates when
    1.43 +   there are no remaining unvisited positions."
    1.44    [comparator successors initial-nodes]
    1.45    (let [initial-nodes
    1.46  	(apply (partial sorted-set-by comparator) initial-nodes)
    1.47 @@ -388,30 +391,32 @@
    1.48    (comparatize susceptance))
    1.49  
    1.50  (defn type-successors
    1.51 -  "Return the set of types that can be made by appending a single type
    1.52 -to the given combination."
    1.53 +  "Return the set of types that can be made by appending a
    1.54 +single type to the given combination."
    1.55    [type]
    1.56    (if (nil? type) '()
    1.57        (set (map (comp vec sort (partial into type)) (multitypes 1)))))
    1.58  
    1.59  (defn immortal?
    1.60 -  "A type combo is immortal if it is resistant or invulnerable to
    1.61 -  every pokemon type. This is because that set of types can just be
    1.62 -  repeated to achieve as low a susceptance as desired"
    1.63 +  "A type combo is immortal if it is resistant or
    1.64 +  invulnerable to every pokemon type. This is because that
    1.65 +  set of types can just be repeated to achieve as low a
    1.66 +  susceptance as desired"
    1.67    [type]
    1.68    (every? (partial > 1) (vals (susceptibility type))))
    1.69  
    1.70  (defn type-successors*
    1.71 -  "Stop expanding a type if it's immortal, or if it is longer than or
    1.72 -equal to limit-size.  Also, only return type additions that are
    1.73 -strictly better than the initial type."
    1.74 +  "Stop expanding a type if it's immortal, or if it is
    1.75 +longer than or equal to limit-size.  Also, only return type
    1.76 +additions that are strictly better than the initial type."
    1.77    [limit-size type]
    1.78    (if (or (<= limit-size (count type)) (immortal? type)) '()
    1.79 -      (set (filter #(< 0 (type-compare type %)) (type-successors type)))))
    1.80 +      (set (filter #(< 0 (type-compare type %)) 
    1.81 +                   (type-successors type)))))
    1.82  
    1.83  (defn pokemon-type-search
    1.84 -  "Search among type-combos no greater than length n, limited by limit
    1.85 -steps of best-first-search."
    1.86 +  "Search among type-combos no greater than length n,
    1.87 +limited by limit steps of best-first-search."
    1.88    ([n] (pokemon-type-search n Integer/MAX_VALUE))
    1.89    ([n limit]
    1.90       (first (last
    1.91 @@ -527,7 +532,8 @@
    1.92  #+begin_src clojure :results output :exports both
    1.93  (clojure.pprint/pprint
    1.94   (pokemon.types/susceptibility 
    1.95 -  [:dragon :fire :flying :ghost :grass :ground :steel :steel :water :water]))
    1.96 +  [:dragon :fire :flying :ghost :grass :ground 
    1.97 +   :steel :steel :water :water]))
    1.98  #+end_src
    1.99  
   1.100  #+results: