Skip to content

Instantly share code, notes, and snippets.



Last active Jan 30, 2017
What would you like to do?
Calculate prereqs for a universe in ITRTG
#!/usr/bin/env lein-exec
;;; Calculator for manual creations given a CC value
;;; Based on numbers from
;;; Usage: universe.clj <cc> <number of universes>
(require '[clojure.pprint :refer (print-table)])
(defn item-req-times-cc [reqd-for-one cc]
(let [multiplier (case cc
0 0M
1 1.0M
2 1.95M
3 2.85M
4 3.7M
5 4.5M
6 5.25M
7 5.95M
8 6.6M
9 7.2M
(-> cc
(- 10)
(* 0.5M)
(+ 7.75M)))]
(-> reqd-for-one
(* multiplier)
(.setScale 0 (. java.math.RoundingMode HALF_EVEN))
(defn items-needed [items-for-one number-to-build cc]
(let [quotient (quot number-to-build cc)
remainder (rem number-to-build cc)]
(* (item-req-times-cc items-for-one cc) quotient)
(item-req-times-cc items-for-one remainder))))
(defn calc [universe cc]
(let [galaxy (items-needed 5 universe cc)
solar-system (items-needed 5 galaxy cc)
sun (items-needed 10 solar-system cc)
elp (items-needed 1 solar-system cc)
planet (+ (items-needed 1 elp cc) (items-needed 100 solar-system cc))
moon (items-needed 1 planet cc)
night (items-needed 1 moon cc)
sky (items-needed 2 night cc)
weather (items-needed 1 sky cc)
continent (items-needed 1 weather cc)
nation (items-needed 5 continent cc)
ocean (+ (items-needed 1 continent cc) (items-needed 5 weather cc))]
:ocean ocean
:nation nation
:continent continent
:weather weather
:sky sky
:night night
:moon moon
:planet planet
:elp elp
:sun sun
:solar-system solar-system
:galaxy galaxy
:universe universe)))
(defn main [universe cc]
(let [values (calc universe cc)
records (map
(fn [x]
(let [[name needed] x]
{:name name :needed needed}))
(print-table records)))
(let [universe (Integer/parseInt (nth *command-line-args* 1))
cc (Integer/parseInt (nth *command-line-args* 2))]
(main universe cc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.