Browse files

Make radar plot files more usable:

  - Put the solution title into the plot itself.
  - Put the first quality at the 12 o'clock position.
  - Enumerate qualities clockwise. (Works for Europe, Australia, and the Americas.)
  - Use the solution title for the filename instead of just numbering them.
  • Loading branch information...
1 parent d9fb34e commit c33f8fa1de6d2543e7418e508f79d4171e0d826f @mtnygard committed May 25, 2012
Showing with 11 additions and 6 deletions.
  1. +6 −1 src/utree/core.clj
  2. +3 −3 src/utree/parser.clj
  3. +2 −2 src/utree/radial.clj
View
7 src/utree/core.clj
@@ -47,9 +47,14 @@
(dot/emit-dot (:utility world))
world)
+(defn underscore [s] (str/replace s #" " "_"))
+
(defn emit-radar
[idx soln]
- (r/write-radar-display-to-file (s/solution-scores soln) (str "solution_" idx ".png")))
+ (r/write-radar-display-to-file
+ (s/solution-scores soln)
+ (str (underscore (s/solution-title soln)) ".png")
+ :title (s/solution-title soln)))
(defn emit-radars
[world]
View
6 src/utree/parser.clj
@@ -53,7 +53,7 @@
(defn solution-title? [line] (.startsWith line "*"))
-(defn score-lines [soln] (filter #(re-seq #"^[a-zA-Z/ ]*:\s*[0-9]+/[0-9]+$" %) (solution-description soln)))
+(defn score-lines [soln] (filter #(re-seq #"^[a-zA-Z/, ]*:\s*[0-9]+/[0-9]+$" %) (solution-description soln)))
(defn quality-label [score-line]
(-> score-line
@@ -83,8 +83,8 @@
"Return a seq of solutions."
[world lines]
(let [lines (drop-while (comp not solution-title?) lines)]
- (for [[title desc] (partition 2 (partition-by solution-title? lines))]
- (-> (make-solution title)
+ (for [[[title-ln] desc] (partition 2 (partition-by solution-title? lines))]
+ (-> (make-solution (str/replace title-ln #"^\* " ""))
(add-solution-description desc)
(parse-scores world)))))
View
4 src/utree/radial.clj
@@ -27,12 +27,12 @@
(let [theta (/ pi2 (count ds))]
(loop [m []
n 0
- ang (- (/ Math/PI 2.0))
+ ang (/ Math/PI 2.0)
[[_ value domain] & more] (seq ds)]
(if value
(recur (conj m [(scale-fn value domain) ang])
(inc n)
- (+ ang theta)
+ (- ang theta)
more)
m))))

0 comments on commit c33f8fa

Please sign in to comment.