forked from cdwfs/pyaiml
-
Notifications
You must be signed in to change notification settings - Fork 54
/
stress.py
35 lines (30 loc) · 1004 Bytes
/
stress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
This file contains the PyAIML stress test. It creates two bots, and connects
them in a cyclic loop. A lot of output is generated; piping the results to
a log file is highly recommended.
"""
from __future__ import print_function
import aiml
# Create the kernels
kern1 = aiml.Kernel()
kern1.verbose(False)
kern2 = aiml.Kernel()
kern2.verbose(False)
# Initialize the kernels
print( "Initializing Kernel #1" )
kern1.bootstrap(learnFiles="std-startup.xml", commands="load aiml b")
kern1.saveBrain("standard.brn")
print( "\nInitializing Kernel #2" )
kern2.bootstrap(brainFile="standard.brn")
# Start the bots off with some basic input.
response = "askquestion"
# Off they go!
while True:
response = kern1.respond(response).strip()
print( "1:", response, "\n" )
response = kern2.respond(response).strip()
print( "2:", response, "\n" )
# If the robots have run out of things to say, force one of them
# to break the ice.
if response == "":
response = "askquestion"