Skip to content

Instantly share code, notes, and snippets.

@voidlily
Last active January 30, 2017 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voidlily/0ebdef4fd902091d4b3f4885828221d6 to your computer and use it in GitHub Desktop.
Save voidlily/0ebdef4fd902091d4b3f4885828221d6 to your computer and use it in GitHub Desktop.
Calculate prereqs for a universe in ITRTG
#!/usr/bin/env lein-exec
;;; Calculator for manual creations given a CC value
;;; Based on numbers from
;;; http://www.kongregate.com/forums/2874-idling-to-rule-the-gods/topics/453555-creating-a-universe#posts-9414071
;;;
;;; 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))
int)))
(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))]
(array-map
: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}))
values)]
(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