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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file trill-0.0.11.tar.gz.

File metadata

  • Download URL: trill-0.0.11.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for trill-0.0.11.tar.gz
Algorithm Hash digest
SHA256 6799dfc4152d7c8b094764e4a9fc5d58346c45a43151185e1436f83e3794b618
MD5 09d7925e02a9d6e4e699852909acf0b1
BLAKE2b-256 aa8d182d2b74dd441a2b10fff5c99d3b186f6b634b3d5b976ae00851b14f5507

See more details on using hashes here.

File details

Details for the file trill-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: trill-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 32.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for trill-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 704d3787c60799d13cea0423a6b05b9edb697a7f5c8a88d1db6573c799ab24d9
MD5 250ab48f61d6901fb510189b35e47750
BLAKE2b-256 16a8ed24cff44621fbc02b76a616495c6af5a58be7e5f63bb79a80c2bcbf0841

See more details on using hashes here.

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