guyblade.com #/


PSN
Gamercard


2009 Nov 21 elly


Guy Blade Guy Blade---04:50:00


Useful formulations
The following scheme code calculates the chance of succeeding at a skill challenge in fourth edition D&D at a given DC by a character with a certain skill. It assumes that you must get succ successes before getting fail failures.


(define fourth-ed-skill-contest
(lambda (dc skill succ fail)
(letrec ((pds (/ (+ 20 (- dc) skill) 20))
(n (+ succ fail -1))
(fact (lambda (n) (if (= 0 n) 1 (* n (fact (- n 1))))))
(cn (lambda (n k) (/ (fact n) (* (fact k) (fact (- n k))))))
(msum (lambda (i accum)
(if (>= i fail) accum
(let ((iprob (* (cn n i) (expt pds (- n i)) (expt (- 1 pds) i))))
(msum
(+ i 1)
(+ accum iprob)))))))
(msum 0 0))))


Published by XPostGTK+


Permalink to this post     Com/0

Front Page

Archive
Copyright 2002-2024 Blade Libergnosis//Powered By Blogger