Top-Down and Bottom-Up Programming

Channel:
Subscribers:
2,640
Published on ● Video Link: https://www.youtube.com/watch?v=7isi2RkgutQ



Duration: 1:14:38
131 views
2


Today we ran through the implementation, in about an hour, of a dice roller for a roleplaying game called Legend of the Five Rings (4th Edition). It uses an interesting dice system, in which you roll X 10-sided dice, and keep the Y greatest of them, adding the results together to get your result. So, for example, if you roll 6k3 for damage, then you might roll six dice like this:
1 7 2 4 3 9


And then keep the top 3 of them:
9 7 4


Adding them together, you get 20.


If you want to figure out what the average result of 6k3 is, then you need to either figure it out directly using the power of math (which I'm not smart enough to do) or do a Monte Carlo simulation in which you repeatedly run the random value generation and average the results together.


There's a lot of ways you can code that, and so in class today I showed how I went about breaking the problem down into pieces, and using "drivers" and "stubs" to allow me to write the code a little bit at a time. A driver is when main calls your functions to test them. A stub is a fake function that returns a value that's kinda-sorta plausible that you can use to allow you to write higher level functions without needing all of the lower level stuff implemented first.







Tags:
csci 40
drivers
stubs
top-down
bottom-up
C++
L5R
roll and keep
Legend of the Five Rings
Dice Roller
Monte Carlo