TabletopAssistant / DiceKit

Swift framework for expressing and evaluating dice notation (e.g., d20, 4d6+4, 3d8×10+2), which is commonly used in tabletop role-playing games.
Apache License 2.0
14 stars 1 forks source link

Probability mass #42

Closed brentleyjones closed 9 years ago

brentleyjones commented 9 years ago

Closes #58.

I'm not doing the equality tests as part of this. I want to refactor those so they are very easy to test for anything that implements Equatable (#54).

JonathanHoffman commented 9 years ago

adding two discrete variables is more like xor I think? Multiply is like P(both of these happen) so I think and is appropriate. I don't know if we want a more descriptive function name. Let me get back to you after coffee.

brentleyjones commented 9 years ago

They aren't exactly xor or or, so or fits better when thinking of saying the following: "I can get heads or tails" or "I can get 1 or 2 or 3 or 4 or 5 or 6". It's a way to build it up. Similar is "I can get (heads or tails) and (heads or tails) and (heads or tails)".

brentleyjones commented 9 years ago

I see how it is actually xor. I'll think on that one. I think xor makes sense for probability, but most people think of it as "or" verbally. So the inner one can be xor while the outer operator can still be be || maybe?

brentleyjones commented 9 years ago

Ignore all of the above, I renamed it to xor and made a logical xor operator ^^.

brentleyjones commented 9 years ago

@TabletopAssistant/dicekit This is ready for code review. I'll do the documentation and playground in the next day or two (and I'll ping everyone again then).

JonathanHoffman commented 9 years ago

I think the names for the methods are fine. I only pointed out code style things. Other than that, :+1:

JonathanHoffman commented 9 years ago

Also, README and Playground. Just noticed that they are still on your list.

brentleyjones commented 9 years ago

Finally got around to updating the playground. It made me implement some protocols to make it easier to use. I love playgrounds.

probabilityplayground
brentleyjones commented 9 years ago

@LoganJohnson @JonathanHoffman Ready for final review :tada:

brentleyjones commented 9 years ago

I realized that I need to add tests for the new SequenceType/CollectionType conformance I have/am adding.

JonathanHoffman commented 9 years ago

Wow, I've never seen a frequency distribution like that! Very nice!

brentleyjones commented 9 years ago

Ready for final code review. All tests in. Playground up and running. :dash:

LoganJohnson commented 9 years ago

:+1: Super pumped to see this stuff in action. That probability graph in the playground is the bees knees.

brentleyjones commented 9 years ago

I'll fix the typo soon, then merge if no other comments come up.