# HG changeset patch # User Robert McIntyre # Date 1344288408 14400 # Node ID 0f6ace87343af17e22a0c028be515ea81c0eabf8 # Parent 7698e9bdff2b33d15181fd6cc9c5e2c1ab8cb06d minor typographical changes. diff -r 7698e9bdff2b -r 0f6ace87343a org/lpsolve.org --- a/org/lpsolve.org Mon Aug 06 17:22:39 2012 -0400 +++ b/org/lpsolve.org Mon Aug 06 17:26:48 2012 -0400 @@ -156,7 +156,6 @@ #+name: intro #+begin_src clojure :results silent (ns pokemon.lpsolve - ;;(:use [clojure.contrib def set [seq :only [indexed]] pprint]) (:import lpsolve.LpSolve) (:require pokemon.types) (:require incanter.core) diff -r 7698e9bdff2b -r 0f6ace87343a org/types.org --- a/org/types.org Mon Aug 06 17:22:39 2012 -0400 +++ b/org/types.org Mon Aug 06 17:26:48 2012 -0400 @@ -153,7 +153,8 @@ (def pokemon-gen-one pokemon-table-gen-one) (def pokemon-gen-two pokemon-table-gen-two) -(defn type-names [] (vec (doall (map (comp keyword first) pokemon-gen-two)))) +(defn type-names [] + (vec (doall (map (comp keyword first) pokemon-gen-two)))) (defn attack-strengths [] (zipmap @@ -322,9 +323,10 @@ (in-ns 'pokemon.types) (defn comparatize - "Define a comparator which uses the numerical outputs of fn as its criterion. - Objects are sorted in increasing numerical order. Objects with the same fn-value - are further compared by clojure.core/compare." + "Define a comparator which uses the numerical outputs of + fn as its criterion. Objects are sorted in increasing + numerical order. Objects with the same fn-value are + further compared by clojure.core/compare." [fun] (fn [a b] (let [val-a (fun a) @@ -359,12 +361,13 @@ (defn best-first-search "Searches through a network of alternatives, pursuing -initially-promising positions first. Comparator defines which -positions are more promising, successors produces a list of improved -positions from the given position (if any exist), and initial-nodes is -a list of starting positions. Returns a lazy sequence of search results - [visited-nodes unvisited-nodes], which terminates when -there are no remaining unvisited positions." + initially-promising positions first. Comparator defines + which positions are more promising, successors produces a + list of improved positions from the given position (if + any exist), and initial-nodes is a list of starting + positions. Returns a lazy sequence of search results + [visited-nodes unvisited-nodes], which terminates when + there are no remaining unvisited positions." [comparator successors initial-nodes] (let [initial-nodes (apply (partial sorted-set-by comparator) initial-nodes) @@ -388,30 +391,32 @@ (comparatize susceptance)) (defn type-successors - "Return the set of types that can be made by appending a single type -to the given combination." + "Return the set of types that can be made by appending a +single type to the given combination." [type] (if (nil? type) '() (set (map (comp vec sort (partial into type)) (multitypes 1))))) (defn immortal? - "A type combo is immortal if it is resistant or invulnerable to - every pokemon type. This is because that set of types can just be - repeated to achieve as low a susceptance as desired" + "A type combo is immortal if it is resistant or + invulnerable to every pokemon type. This is because that + set of types can just be repeated to achieve as low a + susceptance as desired" [type] (every? (partial > 1) (vals (susceptibility type)))) (defn type-successors* - "Stop expanding a type if it's immortal, or if it is longer than or -equal to limit-size. Also, only return type additions that are -strictly better than the initial type." + "Stop expanding a type if it's immortal, or if it is +longer than or equal to limit-size. Also, only return type +additions that are strictly better than the initial type." [limit-size type] (if (or (<= limit-size (count type)) (immortal? type)) '() - (set (filter #(< 0 (type-compare type %)) (type-successors type))))) + (set (filter #(< 0 (type-compare type %)) + (type-successors type))))) (defn pokemon-type-search - "Search among type-combos no greater than length n, limited by limit -steps of best-first-search." + "Search among type-combos no greater than length n, +limited by limit steps of best-first-search." ([n] (pokemon-type-search n Integer/MAX_VALUE)) ([n limit] (first (last @@ -527,7 +532,8 @@ #+begin_src clojure :results output :exports both (clojure.pprint/pprint (pokemon.types/susceptibility - [:dragon :fire :flying :ghost :grass :ground :steel :steel :water :water])) + [:dragon :fire :flying :ghost :grass :ground + :steel :steel :water :water])) #+end_src #+results: