NAME

Langertha::Holmgang::Sim::Kueche - The answer world kueche — recipe collection, pantry, shopping list, week plan, units

VERSION

version 0.001

SYNOPSIS

# suite.yaml: every tool names the world, the tool's name picks what it does
tools:
  - { name: auf_liste_setzen, simulator: kueche, description: …, parameters: { … } }

my $sims = Langertha::Holmgang::Simulators->new;
my ( $output, $ok ) = $sims->tool_call( $state, kueche => auf_liste_setzen => { zutat => 'Mehl', menge => '2 EL' } );

DESCRIPTION

A world without a device (contract: Langertha::Holmgang::Role::AnswerWorld; type kueche): a kitchen with a recipe collection, pantry, shopping list and week plan. The tools are general and the same for every case; no name gives away a fault. Tool names, parameters and world keys are German, as the model sees them:

rezepte_suchen   { suchbegriff? }                 search titles and ingredients
rezept_lesen     { rezept }                       one recipe (ID or exact title)
vorrat_lesen     { }                              what is in the pantry
liste_lesen      { }                              the shopping list
auf_liste_setzen { zutat, menge }                 add an amount to the list (adds up)
von_liste_nehmen { zutat, menge? }                subtract an amount; without one, strike it entirely
plan_lesen       { }                              the week plan
plan_setzen      { tag, rezept, portionen }       set a dish for one day

Units

The tools take amounts in any form the measure table knows ("2 EL", "30 g", "0,5 l", "3", "2 Dosen"). The world converts them into the base unit of the ingredient (weight g, volume ml or a count unit such as Stück, Dose, Zehe), so grading compares only numbers. Spoons are kitchen measures: 1 EL (tablespoon) = 15 g or 15 ml, 1 TL (teaspoon) = 5 g or 5 ml. Weight and volume are never converted into each other; what does not fit, the tool refuses like a scale would („Mehl wird in g geführt", flour is kept in g).

Vague amounts (Prise, etwas, nach Belieben, ranges — a pinch, some, to taste) are not in the table; a generator makes no cases from them.

State

kueche:
  type: kueche
  zutaten: { Ei: { einheit: Stück, namen: [Eier] }, Mehl: { einheit: g } }
  rezepte: { apfelkuchen: { titel, portionen, zeit, vegetarisch, nuesse, zutaten: [ { zutat, menge, text } ], quelle } }
  vorrat:  { Mehl: 1000, Salz: vorhanden }   # base unit of the ingredient; without an amount: text
  liste:   { Ei: 2 }               # base unit of the ingredient
  plan:    { Montag: { rezept: apfelkuchen, portionen: 4 } }

zutaten (ingredients) gives each ingredient its base unit (einheit) and further names the tools accept it under (namen, e.g. the plural). rezepte (recipes) is the collection by ID: vegetarisch is ja, vegan or nein, zeit the preparation time in minutes; the tools do not read nuesse (nuts; for a case's rules). menge (amount) in a recipe line is in the ingredient's base unit, text is the line as the recipe writes it; a line without an amount (Salz, „1 Prise Zucker") has no menge, and its ingredient is in the pantry (vorrat) as vorhanden (present).

An ingredient not listed in zutaten goes on the list (liste) with the base unit of its amount; auf_liste_setzen then enters it into zutaten with that einheit.

Only the state, deterministic, neutral.

device_type

kueche.

tools

my $tools = $world->tools;   # { auf_liste_setzen => [qw( zutat menge )], … }

The tools of this world with their required parameters (for the loader).

tool

my ( $output, $ok ) = $world->tool( $kueche, $name, \%args, $ctx );

A tool call on the state of the kitchen ($kueche is changed). A name not in "tools" is an error.

number

number('1,5');   # 1.5
number('1/2');   # 0.5

A number as recipes write it (comma or point, simple fraction, ½), or undef.

show_number

show_number(1.5);   # "1,5"

unit_of

my ( $dim, $factor ) = unit_of('EL');     # ( 'loeffel', 15 )
my ( $dim, $factor ) = unit_of('Dosen');  # ( 'Dose', 1 )

A unit from the measure table, or empty.

parse_amount

my ( $value, $unit, $error ) = parse_amount( '2 EL', 'g' );   # ( 30, 'g' )

Reads an amount and converts it into the base unit $base (g, ml or a count unit; without $base the natural base unit of the amount). Errors as text.

portions

portions(1);   # "1 Portion"

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-holmgang/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.