to make a script or not
Still playing with the idea of making a script file for my Wiwa to read from... it wouldn't be that hard...
A pic of me playing with it. She only has 6 questions so far to play with:
Here's a little code a worked up to test out the theory:
It will need some error proofing, but, It seems like I could just pop a file full of scripted questions for her to ask, and have the bot pick at random from the text file and print them off.
Problem is, if she picks a lot of the same questions over and over, which random does do sometimes, it won't seem very real. But, still playing with all the ideas.
Also, going to play with putting questions into an SQL db, and have her get them from there.... I don't know that it's better.... a text file is very hackable, but takes up so little space, and it's all for fun and learning at the moment. We'll see.
A text file would also mean someone change her to their whim. She'd be easily modifiable. And that would be fun, or really bad....
K, here's the little script line getter:
import sys
from random import randint
filea = sys.argv[1]
# opps.... fixed, didn't have 'arg' in the method:
def get_script_line(arg):
with open(arg) as f:
for i, l in enumerate(f):
pass
count = i
if count != None:
with open(arg) as f:
lines = f.readlines()
x = randint(0, count)
return lines[x]
x = get_script_line(filea)
print(x)
A pic of me playing with it. She only has 6 questions so far to play with:
Here's a little code a worked up to test out the theory:
It will need some error proofing, but, It seems like I could just pop a file full of scripted questions for her to ask, and have the bot pick at random from the text file and print them off.
Problem is, if she picks a lot of the same questions over and over, which random does do sometimes, it won't seem very real. But, still playing with all the ideas.
Also, going to play with putting questions into an SQL db, and have her get them from there.... I don't know that it's better.... a text file is very hackable, but takes up so little space, and it's all for fun and learning at the moment. We'll see.
A text file would also mean someone change her to their whim. She'd be easily modifiable. And that would be fun, or really bad....
K, here's the little script line getter:
import sys
from random import randint
filea = sys.argv[1]
# opps.... fixed, didn't have 'arg' in the method:
def get_script_line(arg):
with open(arg) as f:
for i, l in enumerate(f):
pass
count = i
if count != None:
with open(arg) as f:
lines = f.readlines()
x = randint(0, count)
return lines[x]
x = get_script_line(filea)
print(x)
Comments
Post a Comment