Fri Feb 1 14:52:54 2019 by Enrico Magnani |
Hello! :) I tried to write a program to calculate success probabilities in a system that is like the newest edition of Vampire the Masquerade but using d6 instead of d10. Long story short: roll a pool of d6, success at 4+, every pair of 6 counts as 4 successes. I wrote this: \Number of dice to roll POOL := 8; \Collection of successes C := POOL# 1d6 keep {4,5,6}; \Raw results, need to check for crit rawR := count C; \Raw successes \Count pair of 6 in collection sixR := if 6=C then (count C /2) else 0; \Every pair of 6 counts as 4 successes critR := sixR *4; \Calculate total results totR := rawR - sixR + critR; \Output totR It seems correct, could anyone conferm? Also, I feel I could have written the code better, probably used some unnecessary passage; I'm open to advice :) |
Mon Feb 4 11:52:57 2019 by Enrico Magnani |
I've found an error in the logic of the algorithm: I subtracted the pair of 6s from the collection of results and then added the "modified" value of the critical results to the collection INSTEAD of removing all the 6s from the collection before adding the modified value. I was getting MORE successes then possible :P It should be correct now. Beneath, the edited version. ********** \Number of dice to roll POOL := 10; \Collection of successes C := POOL# 1d6 keep {4,5,6}; \Raw results, need to check for crit rawR := count C; \Raw successes \Count 6 in collection sixR := if 10=C then count C else 0; \Count pair of 6 in collection pairR := sixR / 2; \Every pair of 6 counts as 4 successes critR := pairR *4; \Calculate total results totR := rawR - sixR + critR; \Output totR ********** |
Mon Feb 4 11:55:06 2019 by Enrico Magnani |
Ha! I put a 10 instead of 6 in a condition because I was thinking of d10 :) Edited: ********** \Number of dice to roll POOL := 10; \Collection of successes C := POOL# 1d6 keep {4,5,6}; \Raw results, need to check for crit rawR := count C; \Count 6 in collection sixR := if 6=C then count C else 0; \Count pair of 6 in collection pairR := sixR / 2; \Every pair of 6 counts as 4 successes critR := pairR *4; \Calculate total results totR := rawR - sixR + critR; \Output totR ********** |
Mon Feb 4 12:47:59 2019 by Enrico Magnani |
Ok, next edit, now conditions and operations SHOULD be correct! I would like to delete all the previous entries to avoid confusion... ********** \Number of dice to roll POOL := 3; \Collection of successes C := POOL# 1d6 keep {4,5,6}; \Raw results, need to check for crit rawR := count C; \Count pair of 6 in collection sixR := if 6=C then (count C /2) else 0; \Every pair of 6 counts as 4 successes critR := sixR *4; \Calculate total results totR := rawR - sixR*2 + critR; \Output totR ********** |