| 1 | # Example suite shipped with Langertha-Holmgang, to learn the case DSL from: | ||
| 2 | # a world without a simulator, its one tool described by a handler, and | ||
| 3 | # three cases built by a generate block from a seed. | ||
| 4 | # Origin: written for this distribution; the hills, the beacons and the task | ||
| 5 | # are invented and no real benchmark case (ADR 0003). | ||
| 6 | # Author: Torsten Raudssus <torsten@raudssus.de> | ||
| 7 | # License: same terms as Perl itself (Perl_5), like the distribution. | ||
| 8 | # | ||
| 9 | # holmgang lint share/suites/demo-beacons | ||
| 10 | # holmgang export-yaml share/suites/demo-beacons --out /tmp/exported # the same suite as format 2 | ||
| 11 | # holmgang lint share/suites/demo-beacons --seed demo-beacons=7 # other hills, another suite | ||
| 12 | 1 | ▶ | use Langertha::Holmgang; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | my @HILLS = qw( ashfell brackenhow cragside dunmoor eskrigg fellgate ); | ||
| 15 | |||
| 16 | suite 'demo-beacons' => sub { | ||
| 17 | title 'Demo: a beacon chain, cases from a generator'; | ||
| 18 | description 'An invented chain of hill beacons; a seeded generate block picks which ones to light.'; | ||
| 19 | version 1; | ||
| 20 | topic 'demo'; | ||
| 21 | license 'Perl_5'; | ||
| 22 | source title => 'Langertha-Holmgang example suites', | ||
| 23 | authors => 'Torsten Raudssus <torsten@raudssus.de>', | ||
| 24 | license => 'Perl_5', | ||
| 25 | url => 'https://github.com/Getty/langertha-holmgang'; | ||
| 26 | threshold pass_rate => 1; | ||
| 27 | system_prompt 'You keep the beacon chain of the hills. Light beacons through the tool, then reply briefly without a tool.'; | ||
| 28 | settings max_turns => 6; | ||
| 29 | |||
| 30 | tool light_beacon => ( | ||
| 31 | description => 'Light the beacon on one hill. A lit beacon stays lit.', | ||
| 32 | parameters => { type => 'object', required => ['hill'], | ||
| 33 | properties => { hill => { type => 'string', enum => [@HILLS] } } }, | ||
| 34 | handlers => [ handler match => { hill => '^(?<hill>[a-z]+)$' }, | ||
| 35 | apply => [ { set => 'beacons.{hill}', value => 'lit' } ], | ||
| 36 | output => 'the beacon is lit' ], | ||
| 37 | ); | ||
| 38 | |||
| 39 | # the seed picks the hills; the same seed gives the same three cases | ||
| 40 | generate seed => 1066, sub { | ||
| 41 | my ( $rng ) = @_; | ||
| 42 | for my $n ( 1 .. 3 ) { | ||
| 43 | my ( $first, $second, $other ) = $rng->shuffle(@HILLS); | ||
| 44 | case sprintf( 'light-%02d', $n ) => sub { | ||
| 45 | title 'Light the beacons on '.$first.' and '.$second; | ||
| 46 | difficulty 'leicht'; | ||
| 47 | world beacons => { map { ( $_ => 'dark' ) } @HILLS }; | ||
| 48 | ask 'Light the beacons on '.$first.' and on '.$second.'. Leave every other beacon dark.'; | ||
| 49 | rule $first.' is lit' => at 'beacons.'.$first, equals => 'lit'; | ||
| 50 | rule $second.' is lit' => at 'beacons.'.$second, equals => 'lit'; | ||
| 51 | rule 'no other beacon' => unchanged_except [ 'beacons.'.$first, 'beacons.'.$second ]; | ||
| 52 | solution call( light_beacon => { hill => $first } ), call( light_beacon => { hill => $second } ); | ||
| 53 | alternative 'the other way round' => | ||
| 54 | call( light_beacon => { hill => $second } ), call( light_beacon => { hill => $first } ); | ||
| 55 | wrong 'only the first' => call light_beacon => { hill => $first }; | ||
| 56 | wrong 'a third hill instead of the second' => | ||
| 57 | call( light_beacon => { hill => $first } ), call( light_beacon => { hill => $other } ); | ||
| 58 | }; | ||
| 59 | } | ||
| 60 | }; | ||
| 61 | }; | ||