Odd wish: a digital dice roller for 4th ed


log in or register to remove this ad


Mercule said:
Here goes:
Here's the code from a button that calls it:

Code:
        private void btnRoll_Click(object sender, EventArgs e)
        {
            Dice roller = new Dice(txtFormula.Text);
            lblResult.Text = roller.Roll().ToString();
        }

You should really toss some error handling in there... your class throws an exception for unexpected syntax.

Also, in general the built-in random functions are of pretty poor quality, regardless of language. I haven't done much research in the area, but the Mersenne Twister algorithm seems to be one of the best, and there's a version of it already made for all the popular languages (here's a C# implementation).
 

Asmor said:
You should really toss some error handling in there... your class throws an exception for unexpected syntax.

Such is the nature of things resident in my pile of incomplete projects. And exactly the reason I posted the code with caveat.

Geez.... I post a snippet of code that someone might be able to build off of -- or not -- and I get criticized because it's not full-featured? You're welcome.
 

Asmor said:
You should really toss some error handling in there... your class throws an exception for unexpected syntax.

Also, in general the built-in random functions are of pretty poor quality, regardless of language. I haven't done much research in the area, but the Mersenne Twister algorithm seems to be one of the best, and there's a version of it already made for all the popular languages (here's a C# implementation).

That's amazing... I just sat to read this and I was going to post the same thing, only my algorithm comes from this article.

EDIT: Though after further review, the article needs some work. I'll take a look at Trevor Misfeldt's.

I would add a few other methods that allow for grouping dice rolls, for attack, damage, criticals, sheak attacks, secondary damage, etc.
 
Last edited:

Mercule said:
Such is the nature of things resident in my pile of incomplete projects. And exactly the reason I posted the code with caveat.

Geez.... I post a snippet of code that someone might be able to build off of -- or not -- and I get criticized because it's not full-featured? You're welcome.

I apologize if I offended you, it was not my intent. I was just trying to offer some advice.
 

Mercule said:
Such is the nature of things resident in my pile of incomplete projects. And exactly the reason I posted the code with caveat.

Geez.... I post a snippet of code that someone might be able to build off of -- or not -- and I get criticized because it's not full-featured? You're welcome.
I appreciate the post. It's a good helpful start to putting together a more fully featured program. Excellent.
 

Asmor said:
I apologize if I offended you, it was not my intent. I was just trying to offer some advice.

No problem. Internet doesn't carry tone well. It's an evening's work from about six months ago. I mainly just wanted to see if I could get natural syntax for die rolling. I had intended on refining it and packaging it for reuse, but other priorities took over.

I posted it mainly because it was something I'd tried a couple of times before without luck. I figured it might be a useful boost to someone else in the same position.
 

Remove ads

Top