Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Community
General Tabletop Discussion
*Dungeons & Dragons
Introducing the COUNTDOWN DICE Mechanic!
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Cadence" data-source="post: 8928819" data-attributes="member: 6701124"><p>--------------------</p><p>Edit: See post #23 below for a much shorter way to do it.</p><p>[URL unfurl="true"]https://www.enworld.org/threads/introducing-the-countdown-dice-mechanic.695102/page-2#post-8928919[/URL]</p><p>---------------------</p><p></p><p>I think the attached R code using a transition matrix is correct for giving you what turn you run out on.</p><p>[SPOILER="R Code for Using a Transition Matrix"]#Code using transition matrix</p><p></p><p>#Set the number of starting dice</p><p>dat1<-6</p><p></p><p>#Set how many turns to check for</p><p>nturn<-50</p><p></p><p>#Set the number of sides on the dice</p><p>nside<-6</p><p></p><p>#Make the initial state vector</p><p>s1<-c(1,rep(0,dat1))</p><p></p><p>#Transition matrix</p><p>tmat<-matrix(0,ncol=dat1+1,nrow=dat1+1)</p><p>for (i in 1: (dat1+1)){</p><p> temp<-dbinom(((dat1-i+1):0),</p><p> dat1-i+1,(nside-1)/nside)</p><p> tmat[i,(i: (dat1+1))]<-temp</p><p>}</p><p> </p><p>#Get probability it has run out by that turn</p><p>current<-s1%*%tmat</p><p>pendby<-current[dat1+1]</p><p>for (i in 1: (nturn-1)){</p><p> current<-current%*%tmat</p><p> pendby<-c(pendby,current[dat1+1])}</p><p></p><p>#Get probability it has run out on that turn</p><p>pendon<-pendby[1]</p><p>for (i in 2:nturn){</p><p>pendon<-c(pendon,pendby[ i] -pendby[i-1])}</p><p></p><p>pendon<-c(pendon,1-sum(pendon))</p><p>x<-cbind(1: (nturn+1),round(pendon,4),round(c(pendby,1),4))</p><p>colnames(x)=c("Turn","Prob On","Prob By")</p><p>x</p><p>[/SPOILER]</p><p></p><p>The first value of pendon is the probability of running out of dice on turn 1, etc... The last value is the probability it takes more than whatever you set the max number of turns to check for. pendby will give you the probability of running out on that turn or before.</p><p></p><p>I checked it by writing one that did a simulation.</p><p>[SPOILER="R code using a simulation. Make sure settings match the one using the transition matrix."]#Code using a simulation</p><p></p><p>#Set the number of starting dice</p><p>dat1<-6</p><p></p><p>#Set how many turns to check for</p><p>nturn<-50</p><p></p><p>#Set the number of sides on the dice</p><p>nside<-6</p><p></p><p>#Set number of simulations</p><p>nsims<-100000</p><p></p><p>simcount<-rep(0,(nturn+1))</p><p>for (i in 1:nsims){</p><p> curcount<-dat1</p><p> turn<-0</p><p> while ((curcount>0)&(turn<(nturn+1))){</p><p> turn<-turn+1</p><p> curcount<-rbinom(1,curcount,(nside-1)/nside)</p><p> if (curcount==0){simcount[ i]<-turn}</p><p> if ((curcount>0)&(turn==nturn)){simcount[ i]<- (nturn+1)}</p><p> }}</p><p></p><p>table(simcount)/nsims</p><p></p><p></p><p>#Compare them to make sure it worked</p><p></p><p>cbind(1: (nturn+1),round(pendon,4),</p><p> round(table(simcount)/nsims,4))[/SPOILER]</p><p></p><p>Here are the probabilities for starting with three dice and going up to 20 turns. (Remember the last entry is "More than 20").</p><p></p><p> Turn Prob On Prob By</p><p> [1,] 1 0.0046 0.0046</p><p> [2,] 2 0.0239 0.0285</p><p> [3,] 3 0.0462 0.0748</p><p> [4,] 4 0.0640 0.1388</p><p> [5,] 5 0.0752 0.2140</p><p> [6,] 6 0.0802 0.2942</p><p> [7,] 7 0.0805 0.3747</p><p> [8,] 8 0.0773 0.4520</p><p> [9,] 9 0.0720 0.5240</p><p>[10,] 10 0.0655 0.5895</p><p>[11,] 11 0.0586 0.6481</p><p>[12,] 12 0.0517 0.6999</p><p>[13,] 13 0.0451 0.7450</p><p>[14,] 14 0.0391 0.7841</p><p>[15,] 15 0.0336 0.8176</p><p>[16,] 16 0.0287 0.8464</p><p>[17,] 17 0.0244 0.8708</p><p>[18,] 18 0.0207 0.8915</p><p>[19,] 19 0.0175 0.9090</p><p>[20,] 20 0.0148 0.9238</p><p>[21,] 21 0.0762 1.0000</p><p></p><p>Here it is for six dice</p><p></p><p> Turn Prob On Prob By</p><p> [1,] 1 0.0000 0.0000</p><p> [2,] 2 0.0008 0.0008</p><p> [3,] 3 0.0048 0.0056</p><p> [4,] 4 0.0137 0.0193</p><p> [5,] 5 0.0265 0.0458</p><p> [6,] 6 0.0408 0.0866</p><p> [7,] 7 0.0538 0.1404</p><p> [8,] 8 0.0639 0.2043</p><p> [9,] 9 0.0703 0.2746</p><p>[10,] 10 0.0730 0.3475</p><p>[11,] 11 0.0725 0.4201</p><p>[12,] 12 0.0697 0.4898</p><p>[13,] 13 0.0652 0.5550</p><p>[14,] 14 0.0597 0.6148</p><p>[15,] 15 0.0538 0.6685</p><p>[16,] 16 0.0478 0.7163</p><p>[17,] 17 0.0419 0.7583</p><p>[18,] 18 0.0365 0.7948</p><p>[19,] 19 0.0315 0.8263</p><p>[20,] 20 0.0271 0.8534</p><p>[21,] 21 0.1466 1.0000</p><p></p><p>Edit: I think I fixed all the auto-emoji and mark-up making in the code snippets.</p></blockquote><p></p>
[QUOTE="Cadence, post: 8928819, member: 6701124"] -------------------- Edit: See post #23 below for a much shorter way to do it. [URL unfurl="true"]https://www.enworld.org/threads/introducing-the-countdown-dice-mechanic.695102/page-2#post-8928919[/URL] --------------------- I think the attached R code using a transition matrix is correct for giving you what turn you run out on. [SPOILER="R Code for Using a Transition Matrix"]#Code using transition matrix #Set the number of starting dice dat1<-6 #Set how many turns to check for nturn<-50 #Set the number of sides on the dice nside<-6 #Make the initial state vector s1<-c(1,rep(0,dat1)) #Transition matrix tmat<-matrix(0,ncol=dat1+1,nrow=dat1+1) for (i in 1: (dat1+1)){ temp<-dbinom(((dat1-i+1):0), dat1-i+1,(nside-1)/nside) tmat[i,(i: (dat1+1))]<-temp } #Get probability it has run out by that turn current<-s1%*%tmat pendby<-current[dat1+1] for (i in 1: (nturn-1)){ current<-current%*%tmat pendby<-c(pendby,current[dat1+1])} #Get probability it has run out on that turn pendon<-pendby[1] for (i in 2:nturn){ pendon<-c(pendon,pendby[ i] -pendby[i-1])} pendon<-c(pendon,1-sum(pendon)) x<-cbind(1: (nturn+1),round(pendon,4),round(c(pendby,1),4)) colnames(x)=c("Turn","Prob On","Prob By") x [/SPOILER] The first value of pendon is the probability of running out of dice on turn 1, etc... The last value is the probability it takes more than whatever you set the max number of turns to check for. pendby will give you the probability of running out on that turn or before. I checked it by writing one that did a simulation. [SPOILER="R code using a simulation. Make sure settings match the one using the transition matrix."]#Code using a simulation #Set the number of starting dice dat1<-6 #Set how many turns to check for nturn<-50 #Set the number of sides on the dice nside<-6 #Set number of simulations nsims<-100000 simcount<-rep(0,(nturn+1)) for (i in 1:nsims){ curcount<-dat1 turn<-0 while ((curcount>0)&(turn<(nturn+1))){ turn<-turn+1 curcount<-rbinom(1,curcount,(nside-1)/nside) if (curcount==0){simcount[ i]<-turn} if ((curcount>0)&(turn==nturn)){simcount[ i]<- (nturn+1)} }} table(simcount)/nsims #Compare them to make sure it worked cbind(1: (nturn+1),round(pendon,4), round(table(simcount)/nsims,4))[/SPOILER] Here are the probabilities for starting with three dice and going up to 20 turns. (Remember the last entry is "More than 20"). Turn Prob On Prob By [1,] 1 0.0046 0.0046 [2,] 2 0.0239 0.0285 [3,] 3 0.0462 0.0748 [4,] 4 0.0640 0.1388 [5,] 5 0.0752 0.2140 [6,] 6 0.0802 0.2942 [7,] 7 0.0805 0.3747 [8,] 8 0.0773 0.4520 [9,] 9 0.0720 0.5240 [10,] 10 0.0655 0.5895 [11,] 11 0.0586 0.6481 [12,] 12 0.0517 0.6999 [13,] 13 0.0451 0.7450 [14,] 14 0.0391 0.7841 [15,] 15 0.0336 0.8176 [16,] 16 0.0287 0.8464 [17,] 17 0.0244 0.8708 [18,] 18 0.0207 0.8915 [19,] 19 0.0175 0.9090 [20,] 20 0.0148 0.9238 [21,] 21 0.0762 1.0000 Here it is for six dice Turn Prob On Prob By [1,] 1 0.0000 0.0000 [2,] 2 0.0008 0.0008 [3,] 3 0.0048 0.0056 [4,] 4 0.0137 0.0193 [5,] 5 0.0265 0.0458 [6,] 6 0.0408 0.0866 [7,] 7 0.0538 0.1404 [8,] 8 0.0639 0.2043 [9,] 9 0.0703 0.2746 [10,] 10 0.0730 0.3475 [11,] 11 0.0725 0.4201 [12,] 12 0.0697 0.4898 [13,] 13 0.0652 0.5550 [14,] 14 0.0597 0.6148 [15,] 15 0.0538 0.6685 [16,] 16 0.0478 0.7163 [17,] 17 0.0419 0.7583 [18,] 18 0.0365 0.7948 [19,] 19 0.0315 0.8263 [20,] 20 0.0271 0.8534 [21,] 21 0.1466 1.0000 Edit: I think I fixed all the auto-emoji and mark-up making in the code snippets. [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Dungeons & Dragons
Introducing the COUNTDOWN DICE Mechanic!
Top