NAME

POE::Component::AI::MegaHAL - A non-blocking wrapper around AI::MegaHAL.

SYNOPSIS

    use POE qw(Component::AI::MegaHAL);

    my $poco = POE::Component::AI::MegaHAL->spawn( autosave => 1, debug => 0, 
					      	   path => '.', options => { trace => 0 } );

    POE::Session->create(
	package_states => [
		'main' => [ qw(_start _got_reply) ],
	],
    );

    $poe_kernel->run();
    exit 0;

    sub _start {
	$_[KERNEL]->post( $poco->session_id() => do_reply => { text => 'What is a MegaHAL ?', event => '_got_reply' } );
	undef;
    }

    sub _got_reply {
	print STDOUT $_[ARG0]->{reply} . "\n";
	$_[KERNEL]->post( $poco->session_id() => 'shutdown' );
	undef;
    }

DESCRIPTION

POE::Component::AI::MegaHAL provides a non-blocking wrapper around AI::MegaHAL.

METHODS

spawn

Accepts a number of arguments:

'autosave' and 'path' are passed to AI::MegaHAL; 
'debug' sets the debug mode;
'options' is a hashref of parameters to pass to the component's POE::Session; 
'alias', is supported for using POE::Kernel aliases;
session_id

Returns the component session id.

INPUT

These are the events that we'll accept.

All megahal related events accept a hashref as the first parameter. You must specify 'event' as the event in your session where you want the response to go. See the example in the SYNOPSIS.

The 'shutdown' event doesn't require any parameters.

intial_greeting

Solicits the initial greeting returned by the brain on start-up.

do_reply

Submits text to the brain and solicits a reply. In the hashref you must specify 'text' with the data you wish to submit to the AI::MegaHAL object.

learn

Submits text to the brain without soliciting a reply. In the hashref you must specify 'text' with the data you wish to submit to the AI::MegaHAL object.

_cleanup

Saves the megahal brain to file.

shutdown

Shuts the component down gracefully. Any pending requests will be serviced and return events dispatched.

OUTPUT

Events generated by the component in response to the above input will have a hashref as ARG0. $hashref->{reply} will contain the applicable response from the brain.

AUTHOR

Chris 'BinGOs' Williams

with contributions by David Davies <xantus>.

LICENSE

Copyright © Chris Williams and David Davis

This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.

SEE ALSO

AI::MegaHAL

http://megahal.sourceforge.net/

POE