changeset 17:0f6ace87343a

minor typographical changes.
author Robert McIntyre <rlm@mit.edu>
date Mon, 06 Aug 2012 17:26:48 -0400
parents 7698e9bdff2b
children 2bec94944460
files org/lpsolve.org org/types.org
diffstat 2 files changed, 28 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/lpsolve.org	Mon Aug 06 17:22:39 2012 -0400
     1.2 +++ b/org/lpsolve.org	Mon Aug 06 17:26:48 2012 -0400
     1.3 @@ -156,7 +156,6 @@
     1.4  #+name: intro
     1.5  #+begin_src clojure :results silent
     1.6  (ns pokemon.lpsolve
     1.7 -  ;;(:use [clojure.contrib def set [seq :only [indexed]] pprint])
     1.8    (:import lpsolve.LpSolve)
     1.9    (:require pokemon.types)
    1.10    (:require incanter.core)
     2.1 --- a/org/types.org	Mon Aug 06 17:22:39 2012 -0400
     2.2 +++ b/org/types.org	Mon Aug 06 17:26:48 2012 -0400
     2.3 @@ -153,7 +153,8 @@
     2.4  (def pokemon-gen-one pokemon-table-gen-one)
     2.5  (def pokemon-gen-two pokemon-table-gen-two)
     2.6  
     2.7 -(defn type-names [] (vec (doall (map (comp keyword first) pokemon-gen-two))))
     2.8 +(defn type-names [] 
     2.9 +  (vec (doall (map (comp keyword first) pokemon-gen-two))))
    2.10  
    2.11  (defn attack-strengths []
    2.12       (zipmap
    2.13 @@ -322,9 +323,10 @@
    2.14  (in-ns 'pokemon.types)
    2.15  
    2.16  (defn comparatize
    2.17 -  "Define a comparator which uses the numerical outputs of fn as its criterion.
    2.18 -   Objects are sorted in increasing numerical order. Objects with the same fn-value
    2.19 -   are further compared by clojure.core/compare."
    2.20 +  "Define a comparator which uses the numerical outputs of
    2.21 +   fn as its criterion.  Objects are sorted in increasing
    2.22 +   numerical order. Objects with the same fn-value are
    2.23 +   further compared by clojure.core/compare."
    2.24    [fun]
    2.25    (fn [a b]
    2.26      (let [val-a (fun a)
    2.27 @@ -359,12 +361,13 @@
    2.28  
    2.29  (defn best-first-search
    2.30    "Searches through a network of alternatives, pursuing
    2.31 -initially-promising positions first. Comparator defines which
    2.32 -positions are more promising, successors produces a list of improved
    2.33 -positions from the given position (if any exist), and initial-nodes is
    2.34 -a list of starting positions.  Returns a lazy sequence of search results
    2.35 - [visited-nodes unvisited-nodes], which terminates when 
    2.36 -there are no remaining unvisited positions."
    2.37 +   initially-promising positions first. Comparator defines
    2.38 +   which positions are more promising, successors produces a
    2.39 +   list of improved positions from the given position (if
    2.40 +   any exist), and initial-nodes is a list of starting
    2.41 +   positions.  Returns a lazy sequence of search results
    2.42 +   [visited-nodes unvisited-nodes], which terminates when
    2.43 +   there are no remaining unvisited positions."
    2.44    [comparator successors initial-nodes]
    2.45    (let [initial-nodes
    2.46  	(apply (partial sorted-set-by comparator) initial-nodes)
    2.47 @@ -388,30 +391,32 @@
    2.48    (comparatize susceptance))
    2.49  
    2.50  (defn type-successors
    2.51 -  "Return the set of types that can be made by appending a single type
    2.52 -to the given combination."
    2.53 +  "Return the set of types that can be made by appending a
    2.54 +single type to the given combination."
    2.55    [type]
    2.56    (if (nil? type) '()
    2.57        (set (map (comp vec sort (partial into type)) (multitypes 1)))))
    2.58  
    2.59  (defn immortal?
    2.60 -  "A type combo is immortal if it is resistant or invulnerable to
    2.61 -  every pokemon type. This is because that set of types can just be
    2.62 -  repeated to achieve as low a susceptance as desired"
    2.63 +  "A type combo is immortal if it is resistant or
    2.64 +  invulnerable to every pokemon type. This is because that
    2.65 +  set of types can just be repeated to achieve as low a
    2.66 +  susceptance as desired"
    2.67    [type]
    2.68    (every? (partial > 1) (vals (susceptibility type))))
    2.69  
    2.70  (defn type-successors*
    2.71 -  "Stop expanding a type if it's immortal, or if it is longer than or
    2.72 -equal to limit-size.  Also, only return type additions that are
    2.73 -strictly better than the initial type."
    2.74 +  "Stop expanding a type if it's immortal, or if it is
    2.75 +longer than or equal to limit-size.  Also, only return type
    2.76 +additions that are strictly better than the initial type."
    2.77    [limit-size type]
    2.78    (if (or (<= limit-size (count type)) (immortal? type)) '()
    2.79 -      (set (filter #(< 0 (type-compare type %)) (type-successors type)))))
    2.80 +      (set (filter #(< 0 (type-compare type %)) 
    2.81 +                   (type-successors type)))))
    2.82  
    2.83  (defn pokemon-type-search
    2.84 -  "Search among type-combos no greater than length n, limited by limit
    2.85 -steps of best-first-search."
    2.86 +  "Search among type-combos no greater than length n,
    2.87 +limited by limit steps of best-first-search."
    2.88    ([n] (pokemon-type-search n Integer/MAX_VALUE))
    2.89    ([n limit]
    2.90       (first (last
    2.91 @@ -527,7 +532,8 @@
    2.92  #+begin_src clojure :results output :exports both
    2.93  (clojure.pprint/pprint
    2.94   (pokemon.types/susceptibility 
    2.95 -  [:dragon :fire :flying :ghost :grass :ground :steel :steel :water :water]))
    2.96 +  [:dragon :fire :flying :ghost :grass :ground 
    2.97 +   :steel :steel :water :water]))
    2.98  #+end_src
    2.99  
   2.100  #+results: