Skip to main content

Troll language parser and interpreter.

Project description

Trill is a Troll interpreter

Implemented in Python both as a package and for command line use.

Troll is a dice roll language made by Torben Mogensen
http://hjemmesider.diku.dk/~torbenm/Troll/

Command line usage

Rolling a single die: trill d12

Rolling multiple die: trill 3d6

Use from a python script

from trill import trill

result, errors = trill("3d6")

See further examples in the examples folder.

Running tests

make test

Running coverage

make coverage

Development

Currently in a very early state. Most of the notation is not yet implemented. See the list below for what is, and what is not (supposed) to work yet.

Notation

(From summary on quick reference http://hjemmesider.diku.dk/~torbenm/Troll/quickRef.html)

  • roll one dn (1 - n)
  • roll m dn
  • roll one zn (0 - n)
  • roll m zn
  • arithmetic on single value (+ - * / mod)
  • sgn, sign of number
  • sum, add up values in collection
  • count values in collection
  • Union of collections (U or @)
  • Union of elements { }
  • min and max in collection
  • all minimal and all maximal values in collection
  • median value in collection
  • least n and
  • largest n values in collection
  • m samples of e ( # )
  • range of values ( .. )
  • choose value from collection
  • pick n values from collection e
  • filters (< <= > >= = =/=)
  • drop elements
  • keep elements
  • multiset difference ( -- )
  • remove duplicates ( different )
  • conditional ( if-then-else )
  • probability ( ?p )
  • logical and ( & )
  • logical not ( ! )
  • bind x to value of e1 in e2 ( x := e1; e2 )
  • foreach x in e1 do e2
  • repeat x := e1 while/until e2
  • accumulate x := e1 while/until e2
  • function
  • compositional
  • call
  • text box of single sample ( ' )
  • text box of n samples ( n ' )
  • combine text boxes horisontally ( || )
  • combine text boxes vertically, left-aligned ( |> )
  • combine text boxes vertically, right-aligned ( <| )
  • combine text boxes, centre-aligned ( <> )
  • Pair of e1,e2 ( [e1, e2])
  • First component of pair ( %1 )
  • Second component of pair ( %2 )
  • x~v returns value of x if x is defined, else returns v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trill-0.0.11.tar.gz (24.6 kB view hashes)

Uploaded Source

Built Distribution

trill-0.0.11-py3-none-any.whl (32.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page