index.md.txt 974 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # XDice
  2. *xdice* is a lightweight python library for managing dice, scores, and dice-notation patterns.
  3. It allows to easily interpret literal expressions as rolls of dice ('1d6', '3d4+3', '12d6+1d4'...etc.), then manipulate the results.
  4. ### Python Versions
  5. DiceRollParser has been tested with python 3.3+
  6. ### Examples
  7. import dice
  8. ## Roll simple dices with **rolldice()**
  9. score = rolldice(6, amount=2)
  10. # manipulates score as an integer
  11. print( score, score * 2, score == 11 )
  12. >> 11 22 True
  13. # Iterates over the results
  14. for result in score:
  15. print(result)
  16. >> 5
  17. >> 6
  18. # Parse patterns with **roll()**
  19. ps = roll("2d6+18")
  20. print( ps, ps.format() )
  21. >> 28 '[5,6]+18'
  22. ### Contribution
  23. Any opinion / contribution is welcome, please contact us.
  24. ### Installation
  25. pip install xdice
  26. ### License
  27. *xdice* is under GNU License
  28. ### Tags
  29. dice roll d20 game random parser dices role board