My Master Voice

One part of AD&D that I allays loved and why I played it for so long was its story telling nature. I can't tell you how many reams of paper myself and the rest of us players and DMs produced in our epic mutil-year game, Still have a few stuffed upstairs in the attice where they where shoved after life caught up with me and my cohorts and the joys or, wives, husband, jobs, houses and kids overtook our game.

It was the 'in-character' and 'NPC' conversions that where always best as some of my fellow players where very good at it. One player what an expert at imitating a ranting nut bar that may or may not have some good info for the party a.k.a. 'the old man from scene 24'.

scene24.jpg

Well I was wondering if there as a way to add this sort of thing into my game rather than the rather stale, tablets or very expensive 'cut out' videos many of todays games.

Well I stumbled across a little bit of AI the other day that would at least help out on the insane babble side of things for me. It is of course the granddaddy of all chatter-bots MegaHAL and we have an interface for it AI::MegaHAL

hal.jpg

The key to using MegaHAL is like any pet training it. Basically you fill it full of text and at some point it begins to spit out meaningful responses to your questions.

Using it couldn't be more simple here is an example


use AI::MegaHAL;

my $old_man_24 = AI::MegaHAL->new('Path' => 'D:\blogs', AutoSave => 1);

my @learn=('Ah, hee he he ha!',
'And this enchanter of whom you speak, he has seen the grail?',
'Ha ha he he he he!',
'Where does he live? Old man, where does he live?',
'He knows of a cave, a cave which no man has entered.',
'And the Grail... The Grail is there?',
'Very much danger, for beyond the cave lies the Gorge of Eternal Peril, which no man has ever crossed.',
'But the Grail! Where is the Grail!?',
'Seek you the Bridge of Death.',
'The Bridge of Death, which leads to the Grail?',);

foreach my $line (@learn){
$old_man_24->learn($line);
}

my $question = "Where does he live old man ";
print $question."\n";
my $text = $old_man_24->do_reply($question );

print $text."\n";
$question = "It leads to the enchanter";
print $question."\n";
$text = $old_man_24->do_reply($question);
print $text."\n";


well I eliminated the 20 other lines of code that slurped in this page and a few doz other from the sacred-texts archive.

and I got this conversation


Where does he live old man
He he he!
It leads to the enchanter
Laugh hard, it's a long way to the enchanter.

It does take a long time to fill HAL up with enough stuff to make coherent sentences come out but sometimes utter rubbish comes out like

Where does he live old man
A maze is a group of primates closely related to the enchanter.
It leads to the enchanter
The left path is true the right path is true the right path is true the right is true?

But the neat thing is the last answer contains the info this NPC is suppose to deliver. So lots fun potential for my game in this little bit of perl.

The stuff you feed to MegaHal is stored in its 'brain' file. So if I was going to use it in a game I would train up one 'brain' with the base storyline and characters then take this brain store it in another folder then train it up$ for the character in question, It really dose not take long for it spew out the correct answer if you as the right question.

Anyway some fun stuff to work with??

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations