campaul / dicebox Goto Github PK
View Code? Open in Web Editor NEWPython library for rolling dice
License: MIT License
Python library for rolling dice
License: MIT License
It would be nice if the user could provide an RNG to use. I can see use cases for having at least a bell curve and a crypto RNG, in addition to the built in uniform RNG.
Does d(10) * d(10)
have any meaning? If so, which side gets turned into an int? If not how can this provide a useful error message?
When you add a constant to a die object, that constant is effectively treated as a die that can only roll its value (i.e., d(10) + 5
is effectively 2 dice—one which can roll 1..10 and one which can only roll 5).
This interacts with the >>
operator in a potentially non-intuitive way:
$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from dicebox import d
>>> roll = 3 * d(5) + 6
>>> roll()
[1, 3, 5, 6]
>>> (roll >> 2)()
[5, 6]
This can be avoided by properly sequencing operations; the above should really be
((3 * d(5)) >> 2) + 6
instead of (3 * d(5) + 6) >> 2
. However, it may be worth making the two Sort
operations ignore Add
s.
The operator based API is fun, but it's not as powerful as the decorator based approach used internaly. Note: decorator
here is referring to the pattern, not Python decorators.
Doing something like d(10).times(1).plus(5)
might be useful.
The d
function can be expanded to understand more than just numbers. For example, the user might do something like d('20e')
for an exploding d20. This could also be the mechanism for specifying RNGs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.