AI-MegaHAL

 view release on metacpan or  search on metacpan

MegaHAL.xs  view on Meta::CPAN

megahal_initialize()

char*
megahal_initial_greeting()

int
megahal_command(input)
        char*   input

char*
megahal_do_reply(input,log)
        char*   input
        int     log

void
megahal_learn(input,log)
        char*   input
        int     log

void
megahal_output(output)
        char*   output

char*
megahal_input(prompt)
        char* prompt

void

lib/AI/MegaHAL.pm  view on Meta::CPAN

=head1 BUGS

None known at this time.

=head1 SEE ALSO

POE::Component::AI::MegaHAL - IRC bot,

L<http://teaandbiscuits.org.uk/drupal/node/65> - Irssi IRC bot,

L<Hailo> - A pluggable Markov engine analogous to MegaHAL

=head1 AUTHOR

The Perl AI::MegaHAL interface was written by Cory Spencer <cspencer[at]sprocket.org>.

Now maintained by Alexandr Ciornii <alexchorny[at]gmail.com>.

MegaHAL was originally written by and is copyright Jason Hutchens <hutch[at]ciips.ee.uwa.edu.au>

=cut

libmegahal.c  view on Meta::CPAN

 *						measures of surprise.
 *
 *		Author:		Mr. Jason L. Hutchens (http://www.amristar.com.au/~hutch/)
 *
 *		WWW:		http://megahal.sourceforge.net
 *
 *		Compilation Notes
 *		=================
 *
 *		When compiling, be sure to link with the maths library so that the
 *		log() function can be found.
 *
 *		On the Macintosh, add the library SpeechLib to your project.  It is
 *		very important that you set the attributes to Import Weak.  You can
 *		do this by selecting the lib and then use Project Inspector from the
 *		Window menu.
 *
 *		CREDITS
 *		=======
 *
 *		Amiga (AmigaOS)

libmegahal.c  view on Meta::CPAN

static int width=75;
static int order=5;

static bool typing_delay=FALSE;
static bool noprompt=FALSE;
static bool speech=FALSE;
static bool quiet=FALSE;
static bool nowrap=FALSE;
static bool nobanner=FALSE;

static char *errorfilename = "megahal.log";
static char *statusfilename = "megahal.txt";
static DICTIONARY *words=NULL;
static DICTIONARY *greets=NULL;
static MODEL *model=NULL;

static FILE *errorfp;
static FILE *statusfp;

static DICTIONARY *ban=NULL;
static DICTIONARY *aux=NULL;

libmegahal.c  view on Meta::CPAN

}

/*
   megahal_do_reply --

   Take string as input, and return allocated string as output.  The
   user is responsible for freeing this memory.

  */

char *megahal_do_reply(char *input, int log)
{
    char *output = NULL;

    if (log != 0)
	write_input(input);  /* log input if so desired */

    upper(input);

    make_words(input, words);

    learn(model, words);
    output = generate_reply(model, words);
    capitalize(output);
    return output;
}

/*
   megahal_learn --

   Take string as input and and learn with no output.

  */

void megahal_learn(char *input, int log)
{

    if (log != 0)
	write_input(input);  /* log input if so desired */

    upper(input);

    make_words(input, words);

    learn(model, words);
}

/*
   megahal_initial_greeting --

libmegahal.c  view on Meta::CPAN

{
    va_list argp;

    fprintf(errorfp, "%s: ", title);
    va_start(argp, fmt);
    vfprintf(errorfp, fmt, argp);
    va_end(argp);
    fprintf(errorfp, ".\n");
    fflush(errorfp);

    //    fprintf(stderr, "MegaHAL died for some reason; check the error log.\n");

    exit(1);
}

/*---------------------------------------------------------------------------*/

bool warn(char *title, char *fmt, ...)
{
    va_list argp;

    fprintf(errorfp, "%s: ", title);
    va_start(argp, fmt);
    vfprintf(errorfp, fmt, argp);
    va_end(argp);
    fprintf(errorfp, ".\n");
    fflush(errorfp);

    //    fprintf(stderr, "MegaHAL emitted a warning; check the error log.\n");

    return(TRUE);
}

/*---------------------------------------------------------------------------*/

/*
 *		Function:	Initialize_Status
 *
 *		Purpose:		Close the current status file pointer, and open a new one.

libmegahal.c  view on Meta::CPAN

	    ++num;
	    for(j=0; j<model->order; ++j) if(model->context[j]!=NULL) {

		node=find_symbol(model->context[j], symbol);
		probability+=(float)(node->count)/
		    (float)(model->context[j]->usage);
		++count;

	    }

	    if(count>0.0) entropy-=(float)log(probability/(float)count);
	}

	update_context(model, symbol);
    }

    initialize_context(model);
    model->context[0]=model->backward;
    for(i=words->size-1; i>=0; --i) {
	symbol=find_word(model->dictionary, words->entry[i]);

libmegahal.c  view on Meta::CPAN

	    ++num;
	    for(j=0; j<model->order; ++j) if(model->context[j]!=NULL) {

		node=find_symbol(model->context[j], symbol);
		probability+=(float)(node->count)/
		    (float)(model->context[j]->usage);
		++count;

	    }

	    if(count>0.0) entropy-=(float)log(probability/(float)count);
	}

	update_context(model, symbol);
    }

    if(num>=8) entropy/=(float)sqrt(num-1);
    if(num>=16) entropy/=(float)num;

    return(entropy);
}

libmegahal.c  view on Meta::CPAN

{
    free(word.word);
}

/*===========================================================================*/

/*
 *		$Log: megahal.c,v $
 *		Revision 1.6  2002/10/16 04:32:53  davidw
 *		* megahal.c (change_personality): [ 541667 ] Added patch from Andrew
 *		  Burke to rework logic in change_personality.
 *
 *		* megahal.c: Trailing white space cleanup.
 *
 *		* python-interface.c: [ 546397 ] Change python include path to a more
 *		  recent version.  This should really be fixed by using some of
 *		  Python's build automation tools.
 *
 *		Revision 1.5  2000/11/08 11:07:11  davidw
 *		Moved README to docs directory.
 *

megahal.h  view on Meta::CPAN

#define MEGAHAL_H

void  megahal_setnoprompt ();
void  megahal_setnowrap ();
void  megahal_setnobanner ();
void  megahal_seterrorfile(char *filename);
void  megahal_setstatusfile(char *filename);
void  megahal_initialize();
char* megahal_initial_greeting();
int   megahal_command(char *input);
char* megahal_do_reply(char *input, int log);
void  megahal_learn(char *input, int log);
void  megahal_output(char *output);
char* megahal_input(char *prompt);
void  megahal_cleanup();

#endif

megahal.trn  view on Meta::CPAN

Ants have a complex social structure, and instincts.
The anus is the opening at the end of the alimentary canal.
Apes are a group of primates closely related to humans.
The ass is an animal related to the horse and zebra.
Bacteria are micro organisms.
The bandicoot is a small marsupial peculiar to Australasia.
Bark is the external coating of tree trunks.
The bee is a four winged stinging insect.
Beef is the meat derived from the carcass of bulls and cows.
Behaviour is an organism's mode of life.
Biology is the science of life and living things.
Botany is the science of plant life.
A carnivore is a carnivorous mammal.
Something which is carnivorous eats flesh.
The carrot is a vegetable.
The cat is a carnivorous animal.
A chromosome is a chemical found in all cells which determines how the cell will act.
The cranium is the skeleton enclosing the brain.
The dingo is wild dog found in Australia.
The dinosaurs were a family of reptiles which lived on the earth millions of years ago.
A dog is a domesticated mammal descended from the wolf.
Donkey is another name for ass.
Ecology is a study of the relationship between an organism and its environment.
The emu is a large, ostrich-like flightless bird found in Australia.
Eucalyptus is a tree native to Australia where it is called the gum tree.
Excretion is the process of getting rid of unwanted substances from within the body.
Genes are hereditary information material arranged in a single row along the length of each chromosome.
Gum tree is another name for Eucalyptus.
A herbivore is an animal that eats plants.
The kangaroo is a marsupial mammal found in Australia.
The kiwi is a group of three species of bird only found in New Zealand.
The koala is a marsupial found only in east Australia.
Locomotion is the idea of movement from one place to another.

megahal.trn  view on Meta::CPAN

An alphabet is an ordered series of letters used in language.
An atom is the smallest quantity of a chemical element which can enter into combination or take part in a chemical reaction.
Beer is a drink of fermented hops, malt and barley.
A bicycle is a two wheeled vehicle.
Cement is a mixture of chalk and clay used for building.
Chocolate is a confectionery made from cocoa beans.
A coma is a state of deep unconsciousness.
A compiler is a computer program that translates high level language code into machine language code.
A computer is a programmable electronic device.
Cooking is the art of preparing food for the table by subjecting it to heat in various ways.
Cosmology is the study of the structure of the universe.
The cymbal is a suspended brass disk which is struck with a stick.
Dance is a rhythmic movement of the body usually performed to music.
Data is information, especially that stored in a computer.
A day is the time taken for the earth to rotate once on its axis.
The earth is the third planet from the sun.
A galaxy is a congregation of stars held together by gravity.
Gravity is the force of attraction between two objects resulting from their mass.
A house is a building for human habitation.
Knowledge is practical understanding.
A maze is a confusing network of passages and winding interconnecting paths.



( run in 1.302 second using v1.01-cache-2.11-cpan-49f99fa48dc )