-
-
Save RypoFalem/10845d564efbf4d55f108278aa01d201 to your computer and use it in GitHub Desktop.
sequel command pretty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# % of players that died during an XL of players that reached that XL | |
# Just need two queries, wins at each XL and losses at each XL | |
# the XL deadliness can then be calculated with (deaths / (total - previous_xl_deaths_and_loses)) | |
!cmd xldeathrate .echo $(let* | |
(toHash | |
(fn (lg) (foldr xldeath-helper4 (hash) (split ", " $lg))) | |
xlL | |
(toHash (!lg ${1:-*} $* !won s=xl notitle fmt:"${.} ${n_x}")) | |
xlW | |
(toHash (!lg ${1:-*} $* won s=xl notitle fmt:"${.} ${n_x}")) | |
total | |
(xldeath-helper3 28 $xlW $xlL) | |
result | |
(fn (xl) (concat $xl ": " (sprintf "%2.2f%%" (/ (float (xldeath-helper $xl $xlL)) (- total (xldeath-helper3 $xl $xlW $xlL))))))) | |
(map result (range 1 27))) | |
# get wins/loses at xl from hash. Defaults to 0 (if we didn't find wins/loses at an xl, it won't be in the dictionary) | |
!fn xldeath-helper (xl ha) (with-nvl 0 (elt (str $xl) $ha)) | |
# sum up wins/loses below the limit xl from the hash | |
!fn xldeath-helper2 (limit ha) (foldr (fn (n sum) (+ $n $sum)) 0 (map (fn (xl) (xldeath-helper $xl $ha)) (range 1 (- $limit 1)))) | |
# add the sums of wins and loses below the limit xl | |
!fn xldeath-helper3 (limit wins deaths) (+ (xldeath-helper2 $limit $wins) (xldeath-helper2 $limit $deaths)) | |
# add new data to ha. xlN is in format "27 456x" so we need to remove the x | |
!fn xldeath-helper4 (xlN ha) (hash-put (nth 0 $xlN) (sub 0 -1 (nth 1 $xlN)) $ha) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment