Top-Down and Bottom-Up Programming
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.
Other Videos By Bill Kerney
2021-10-06 | Swimming, Delta Time, Terminator Barrel, UMG HUDs |
2021-10-04 | ACM Talk: Hazelton Teaches Vim |
2021-10-04 | Writing to Files, Error Messages in C++ (scary), and Recursion |
2021-10-04 | Midterm Review + Equivocation Fallacy |
2021-10-02 | Reading from Files in C++ |
2021-10-02 | Fallacies Part I |
2021-09-30 | How to export and import assets between projects in UE4 |
2021-09-30 | Making an AI Enemy Part II |
2021-09-30 | Invalid/Valid/Sound II + Hamiltonian/Eulerian Paths and Cycles |
2021-09-30 | UE4 Damage System and HUDs with UMG |
2021-09-30 | Top-Down and Bottom-Up Programming |
2021-09-29 | Midterm I Review |
2021-09-29 | Making a Castle with the Procedural Spline Walls System |
2021-09-28 | Making an AI Opponent Part I |
2021-09-28 | Graph Theory I |
2021-09-27 | 2D Vectors and Arrays |
2021-09-27 | Scratch Part II |
2021-09-25 | Auto + Growing Vectors + Nonblocking I/O |
2021-09-24 | Introduction to Scratch |
2021-09-23 | Niagara Part II |
2021-09-23 | Landscape + Foliage, Hitscan Weapons, Niagara Particle Effects |