introduction.rst 956 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Introduction
  2. ============
  3. Presentation
  4. ------------
  5. *xdice* is a dice library for Python that provides the main functionality
  6. for managing dice, scores, and dice notation patterns.
  7. DiceRollParser has been tested with python 3.3+.
  8. *xdice* is under GNU License
  9. To install:
  10. ::
  11. pip install xdice
  12. What can it do?
  13. ---------------
  14. * Parse most of common dice notations: '1d6+1', 'd20', '3d%', '1d20//2 - 2*(6d6+2)', 'max(1d4+1,1d6)', '3D6L2', 'R3(1d6+1)'...etc.
  15. * Manipulate Dice, Pattern, and Score as objects.
  16. * Roll trough command-line or API
  17. * Understand any mathematical expression
  18. Examples
  19. ~~~~~~~~
  20. ::
  21. import dice
  22. score = dice.roll("2d6+18")
  23. print(score)
  24. >> 28
  25. print(score*2)
  26. >> 56
  27. print(score.format())
  28. >> '[5,6]+18'
  29. score = dice.roll("6D%L2")
  30. print(ps, ps.format(verbose=True))
  31. >> 315 '6D%L2(scores:[80, 70, 76, 89], dropped:[2, 49])'