Skip to content

Ravath/MightyGeneratorPython

Repository files navigation

MightyGeneratorPython

MightyGm Text generator in python

Generates some text by rolling random results from roll tables.

Get Started

Requirements

  • Python >3.11

Install

  • create venv: python -m venv myenv
  • activate venv: myenv\Scripts\activate
  • install dependencies
    • run pip install -r .\requirements.txt

Run

  • Davido's Borderlands Weapon Generator:
    • CLI
      • run python .\generators\borderlands\gen_david_weapon.py
    • GUI (Kivy)
      • run python .\gui\borderloot\BorderLootApp.py
    • Image Generator
      • run python .\imagenerator\image_arme.py

Project Structure

Generators

Some generation implementations.

GUI

Intended for Android using Kivy (In progress).

Borderloot

A GUI manipulation of the Borderloot generation.

Catalog

A GUI for accessing every implemented generations and executing them.

  • Uses only files prefixed 'gen_'.
  • A generator named 'generation' must be initialized.

Macro

Implementation of dice rolling macros using yacc and ply.

Includes:

  • Rolling dice capacities
  • Mathematical operations

Dice Macros

The initialisation operators create a pool of numbers

  • x : y : returns a number between x and y.
  • x d y : rolls x dice of y faces, returning x numbers between 1 and y.

The filter operators compare every number with a threshold

  • h z : keeps the z higher numbers.
  • l z : keeps the z lower numbers.
  • < z : keeps the numbers higher than z.
  • > z : keeps the numbers lower than z.

The reroll operators reroll the numbers exceding the threshold

  • e z : Explosive Dice : reroll the dice with a result equal or higher than z and adds the result to the previous number.
  • a z : Compound Explosive Dice : Similar to Explosive Dice, except a new dice is added to the pool instead.
  • r z : Reroll Dice : reroll the dice for a new value.
  • if z=-1 (default value) then the threshold value is the maximum value of the dice.
  • if uppercase (E,A,R), then the operation will reiterate as long as the newer results meet the threshold criteria.
  • if followed by <, then the operation will use a lower threshold instead of a higher threshold.
  • if followed by >, then will not have no particular effect. It is just a explicitation of the default behavior.

the suffixes indicate how to interpret the remaining pool

  • <Nothing> : computes the sum by default
  • c : returns the number of results

Exemples

3d6>4c : the number of dice from a 3d6 pool with a result greater or equal than 4.

  • [1,4,6] => 2
  • [1,3,2] => 0

5d10e9 : Rolls 5d10, and then explodes every result greater or equal to 9 and computes the sum.

  • [1,8,9,4,10] => [1,8,(9+5),4,(10+9)] => 46

3d4Ac : Rolls 3d4, and then rolls a new dice for every result greater or equal than 4 (default value), repeats until done, and then counts the number of dice.

  • [1,4,4] => [1,4,3,4,4] => [1,4,3,4,4,2] => 6

3d10r<1 : Rolls 3d10, and then rerolls every result smaller or equal to 1 and computes the sum.

  • [1,8,9] => [6,8,9] => 23

Test

Some testing of the library.

Utils

Some miscellaneous modules.

  • Some debug tools.
  • Some usage examples.

WordGenerator

WordGenerator Readme

How to Use

Outline

  1. Create the tables using the structures from the WordGenerator Module.
  2. Assemble the tables
  3. Use the Generator class to conclude and generate
# exemple from generators/pathfinder/gen_loot_faible.py
from wordgenerator.Weight import WeightNode as Weight

...

# create arborescence
root = Weight() << [
    [ 4, Title("Armure", obj_bouclier_armure)],
    [ 5, Title("Arme", obj_cac_dist)],
    [35, Title("Potion", obj_potion)],
    [ 2, Title("Anneau", obj_anneaux)],
    [35, Title("Parchemin", obj_parchemin)],
    [10, Title("Baguette", obj_baguette)],
    [ 9, Title("Objet Merveilleux", obj_merveilleux)],
]

generation = Generator(root)    # Give the root node to the generator
result = generation.execute()   # Generate a random result
result.print_to_console()       # print the generated result to the console

Generation order

  • Rolls the tables starting from root.
  • Use the {VAR_NAME} syntaxe to include variable results in the generations.
  • Use the [[1d6]] syntaxe to roll dice and apply computations macros.

TODO

  • Check if Dictionnary and SetVar nodes can manage enums instead of string

  • AppendVarNode : same as SetNode, but append instead of set. (or use a flag in SetNode for alternative behavior)

  • Separate the Action nodes and other unrelated objects from the Print.py file

  • Maybe transfert Generator code & logic to NodeIf ?

  • Complete documentation of the generation process on macro level

  • Doc on the Math.Variable objects

  • Complete exemples of new nodes and generation process

  • do some TU ?

  • Complete the Chekpoint node

  • implement nbr_draw in CollectionNode

  • Maybe implement Roll in CollectionNode (remove then from SequenceNode)

  • Implémenter WeighNode.fusion(WeighNode)

  • implémenter contre-mesures contre les récursions dans print_node

About

MightyGm Text generator in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •