comparison org/lpsolve.org @ 13:e1b7ef479bd1

minor edits
author Robert McIntyre <rlm@mit.edu>
date Sun, 05 Feb 2012 11:11:07 -0700
parents 89462678a932
children ecb6e3f9b7d6
comparison
equal deleted inserted replaced
12:89462678a932 13:e1b7ef479bd1
56 - Present our results :: We found some cool examples and learned a lot 56 - Present our results :: We found some cool examples and learned a lot
57 about the pok\eacute{}mon type system as a whole. 57 about the pok\eacute{}mon type system as a whole.
58 58
59 59
60 ** Immortal Types 60 ** Immortal Types
61 61
62 In the game, pok\eacute{}mon can have either one type or two types. If 62 In the game, pok\eacute{}mon can have either one type or two types. If
63 this restriction is lifted, is there any combination of types that is 63 this restriction is lifted, is there any combination of types that is
64 resistant to all types? I call such a combination an /Immortal Type/, 64 resistant to all types? I call such a combination an /Immortal Type/,
65 since if that type's pattern was repeated over and over again towards 65 since if that type's pattern was repeated over and over again towards
66 infinity, the resulting type would be immune to all attack types. 66 infinity, the resulting type would be immune to all attack types.
156 #+begin_src clojure :results silent 156 #+begin_src clojure :results silent
157 (ns pokemon.lpsolve 157 (ns pokemon.lpsolve
158 (:use [clojure.contrib def set [seq :only [indexed]] pprint]) 158 (:use [clojure.contrib def set [seq :only [indexed]] pprint])
159 (:import lpsolve.LpSolve) 159 (:import lpsolve.LpSolve)
160 (:require pokemon.types) 160 (:require pokemon.types)
161 (:require incanter.core)) 161 (:require incanter.core trans)
162 (:require rlm.map-utils))
162 #+end_src 163 #+end_src
163 164
164 The =lp_solve= Java interface is available from the same site as 165 The =lp_solve= Java interface is available from the same site as
165 =lp_solve= itself, http://lpsolve.sourceforge.net/ Using it is the 166 =lp_solve= itself, http://lpsolve.sourceforge.net/ Using it is the
166 same as many other =C= programs. There are excellent instructions to 167 same as many other =C= programs. There are excellent instructions to
319 (filter static-integer? (.getFields class))) 320 (filter static-integer? (.getFields class)))
320 321
321 (defn-memo constant-map 322 (defn-memo constant-map
322 "Takes a class and creates a map of the static constant integer 323 "Takes a class and creates a map of the static constant integer
323 fields with their names. This helps with C wrappers where they have 324 fields with their names. This helps with C wrappers where they have
324 just defined a bunch of integer constants instead of enums" 325 just defined a bunch of integer constants instead of enums."
325 [class] 326 [class]
326 (let [integer-fields (integer-constants class)] 327 (let [integer-fields (integer-constants class)]
327 (into (sorted-map) 328 (into (sorted-map)
328 (zipmap (map #(.get % nil) integer-fields) 329 (zipmap (map #(.get % nil) integer-fields)
329 (map #(.getName %) integer-fields))))) 330 (map #(.getName %) integer-fields)))))
532 :dark 533 :dark
533 :steel] 534 :steel]
534 #+end_example 535 #+end_example
535 536
536 537
537 So, for example, Water is /resistant/ (x0.5) against Fire, which is 538 So, for example, Water is resistant (x0.5) against Fire, which is
538 the second element in the list. 539 the second element in the list.
539 540
540 To combine types, these sorts of vectors are multiplied together 541 To combine types, these sorts of vectors are multiplied together
541 pair-wise to yield the resulting combination. 542 pair-wise to yield the resulting combination.
542 543
1164 :bug 1/2} 1165 :bug 1/2}
1165 #+end_example 1166 #+end_example
1166 1167
1167 Can you see the final step? 1168 Can you see the final step?
1168 1169
1169 It's adding the Water type, which is weak against Water and Dragon and 1170 It's adding the Water type, which is weak against Water, Dragon, and
1170 strong against Rock and Fire. 1171 Grass and strong against Rock and Fire.
1171 1172
1172 #+begin_src clojure :results output :exports both 1173 #+begin_src clojure :results output :exports both
1173 (clojure.pprint/pprint 1174 (clojure.pprint/pprint
1174 (pokemon.lpsolve/attack-mode 1175 (pokemon.lpsolve/attack-mode
1175 (pokemon.types/susceptibility 1176 (pokemon.types/susceptibility