/** * An AIML-ExampleBot for the aimllib by Guru */ import guru.aimllib.*; StringBuffer buffer; String out = "Greetings Human"; Aiml bot; color back = color(128); void setup() { bot = new Aiml( this ); bot.init(createInput("context.xml"), createInput("splitters.xml"), createInput("substitutions.xml"), new InputStream[]{ createInput( "Brain/Brain.aiml" ) }); size(320,200); textFont( loadFont( "BitstreamVeraSans-Roman-16.vlw")); textSize( 16 ); buffer = new StringBuffer(); } void changeColor() { back = color(random(255),random(255),random(255)); } void draw() { background(back); /* println(bot.respond("Hello")); println(bot.respond("Hi")); println(bot.respond("i am test")); println(bot.respond("test that system")); println(bot.respond("bla")); */ fill(0); text( out, 10, 50 ); fill(255); text( buffer.toString(), 10,80 ); } void keyPressed() { if (key == '\n') { out = bot.respond( buffer.toString()); buffer = new StringBuffer(); } else if ( keyCode == 8 ) { if ( buffer.length()>0) { buffer.deleteCharAt( buffer.length()-1 ); } } else { buffer.append( key ); } }