Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perigrin/besoothement-bathymetrical
A Hierarchical Task Network Planner for Perl
https://github.com/perigrin/besoothement-bathymetrical
ai htn-planner perl
Last synced: 23 days ago
JSON representation
A Hierarchical Task Network Planner for Perl
- Host: GitHub
- URL: https://github.com/perigrin/besoothement-bathymetrical
- Owner: perigrin
- Created: 2023-12-02T05:03:49.000Z (about 1 year ago)
- Default Branch: pu
- Last Pushed: 2024-08-21T17:20:29.000Z (5 months ago)
- Last Synced: 2024-08-21T19:33:57.271Z (5 months ago)
- Topics: ai, htn-planner, perl
- Language: Perl
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PLHop
## DESCRIPTION
A Hierarchical Task Network Planner based on Pyhop and it's derivatives.
## SYNOPSIS
```perl
#!/usr/bin/env perl
use 5.38.0;
use lib 'lib';use PLHop;
# Ported From:
# https://github.com/dananau/GTPyhop/blob/main/Examples/pyhop_simple_travel_example.pymy $domain = PLHop::Domain->new( name => 'pyhop_simple_travel_example' );
sub taxi_rate ($dist) { 1.5 + 0.5 * $dist }
$domain->declare_actions(
walk => sub ( $state, $p, $x, $y ) {
return unless $state->{loc}->{$p} eq $x;
$state->{loc}->{$p} = $y;
return $state;
},
call_taxi => sub ( $state, $p, $x ) {
$state->{loc}->{'taxi'} = $x;
return $state;
},
ride_taxi => sub ( $state, $p, $x, $y ) {
return if $state->{loc}->{taxi} ne $x || $state->{loc}->{$p} ne $x;
$state->{loc}->{taxi} = $y;
$state->{loc}->{$p} = taxi_rate( $state->{dist}{$x}{$y} );
return $state;
},
pay_driver => sub ( $state, $p, $y ) {
return if $state->{cash}->{$p} < $state->{owe}->{$p};
$state->{cash}->{$p} = $state->{cash}->{$p} - $state->{owe}->{$p};
$state->{owe}->{$p} = 0;
$state->{loc}->{$p} = $y;
return $state;
},
);sub travel_by_foot ( $state, $p, $x, $y ) {
return unless $state->{dist}->{$x}{$y} <= 2;
return [ 'walk', $p, $x, $y ];
}sub travel_by_taxi ( $state, $p, $x, $y ) {
return unless $state->{cash}->{$p} >= taxi_rate( $state->{dist}{$x}{$y} );
return (
[ 'call_taxi', $p, $x ],
[ 'ride_taxi', $p, $x, $y ],
[ 'pay_driver', $p, $y ]
);
}$domain->declare_task_methods( 'travel', \&travel_by_foot, \&travel_by_taxi );
my $state = {
loc => { me => 'home' },
cash => { me => 20 },
owe => { me => 0 },
dist => { home => { park => 8 }, park => { home => 8 } },
};my $planner = PLHop::Planner->new(
domain => $domain,
state => $state,
todo_list => [ [ 'travel', 'me', 'home', 'park' ] ]
);say "@$_" for $planner->plan();
```