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-1.0.0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trill-1.0.0-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trill-1.0.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for trill-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0354923f22a5b1efb4bd4c405b4aa4241b0c1f263ee45eaa6b794821f9cc85eb
MD5 7893a0fe1d8123ae8fb4120a804fdfa9
BLAKE2b-256 43fa67672e87072a173aa2897b3ef4f94369e3c9e9ffa1172ead3ab884486f86

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trill-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for trill-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ca07c9ae6c595ea267fdb4de3974bc709e86983ee90a5a2d52c54cd9eea366e
MD5 aa579362e3c92d66768c6035dcffdbd3
BLAKE2b-256 4157998b24453cba24a93e633d5725e5689f7eebeea068fd54b2634e764a4e9a

See more details on using hashes here.

Supported by

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