It looks like you're new here. If you want to get involved, click one of these buttons!
Hi people!
This post is the following post from:
http://twolivesleft.com/Codea/Talk/discussion/3617/ai-chatbox#Item_7
I use the following two codes for my program, but I am unable to combine them.
I've tried anything, but have to admit that my knowledge is too short.
When I can combine the "menu" with the " conversation" this little project is good to go ( I suppose)!
The screen/menu:
displayMode(FULLSCREEN)
function setup()
s1=screen1()
s2=screen2()
s3=screen3()
s=1
end
function draw()
fontSize(40)
if s==1 then
s1:draw()
end
if s==2 then
s2:draw()
end
if s==3 then
s3:draw()
end
end
function touched(t)
if t.state==BEGAN then
s=s+1
if s>3 then
s=1
end
end
end
screen1=class()
function screen1:init()
end
function screen1:draw()
background(255, 220, 0, 94)
fill(255,0,0)
text("screen 1",WIDTH/2,HEIGHT/2)
text("tap screen for next screen",WIDTH/2,HEIGHT/2-200)
end
screen2=class()
function screen2:init()
end
function screen2:draw()
background(95, 255, 0, 95)
fill(255,0,0)
text("screen 2",WIDTH/2,HEIGHT/2)
text("tap screen for next screen",WIDTH/2,HEIGHT/2-200)
end
screen3=class()
function screen3:init()
end
function screen3:draw()
background(0, 255, 239, 95)
fill(255,0,0)
text("screen 3",WIDTH/2,HEIGHT/2)
text("tap screen for next screen",WIDTH/2,HEIGHT/2-200)
end
The chat, basic:
function setup()
print("Touch to show Keyboard\nand press return to show a message")
q = {"What is your name?","What is your occupation?"} -- program's questions
a = {"I'm pleased to meet you ","That's an interesting job "} --program's answers
said = false
i=1
memory ={} -- this is for saving answers from user.
end
function draw()
background(255)
textMode(LEFT)
if i<3 then
drawquestion(q[i]) -- drawing the questions
drawanswer(a[i]) -- drawing the answers
end
end
function drawquestion(pre)
text(pre,100,600)
w,h = textSize(pre)
if not said then
memory[i] = keyboardBuffer()
end
if memory[i] then
text(memory[i],100+w+10,600)
end
end
function drawanswer(res)
if i<3 and said then
text(res..memory[i],100,600- h)
end
end
function touched(touch)
if touch.state==ENDED then
showKeyboard()
if said then
i=i+1
end
said = false
end
end
function keyboard(key)
if key == "\n" then
hideKeyboard()
said =true
end
end
I hope this question isn't because I am too unexperienced.
The above codes are unaltered versions from topics on this forum, although I know how to change them.
Combining them would solve my startup issues.
ps: The .lua code from Eliza isn't compatible with codea.
ps2: Thank you so much in advance, again!
Regards
Comments
@jonathanneels Always put 3 tildes ~ on a line before and after your code so it formats right. Pulling sections of code from different programs and thinking that just by combining them you'll have a working program isn't going to work, unless you know what you're doing. These 2 sections of code have nothing to do with each other, so I'm not sure what you're expecting to get by combining them. The chat section seems to work so far, but the screen/menu section isn't going to do anything usefull. What are you trying to accomplish by combining the above code. Maybe then we can help you.
@dave1707
Thank you for the tilde help, I knew I was doing something wrong there...
What I actually want, is to create a startup screen before the basic code.
. I don't seem to understand how to add a splashscreen (and other screens) with the "chat code" above.
That's it
Don't mind the splashscreen code.
Thank you!
(Sorry for my little bit clumsiness.)
Hi @jonathanneels, do you want to have something like a Turing test (http://en.wikipedia.org/wiki/Turing_test)? (because of the 3 screens and the kind of ai interaction you plan to use) If so, I'm interested too! I think, it wouldn't be difficult to combine your two pieces of program, but the interplay between the players (I think). You can concentrate, at a first attempt, on the second piece (ai vs human interaction), because it is not yet totally fine.
Greetings.
Edit: I didn't see your new post.
@jonathanneels Is this something like what you're after.
Try this:
@dave1707 & @Epicpotato:
Yes, both are great and are what I wanted! Thank you so much!
@Quezadav:
Yes, I would like to develop a rather intelligent program where you can have a decent conversation with. It would be great to make it so complex that it passes the Turing test!
On paper I have a great way of "question posing" and "question answering" system, but for now my knowledge is a bit to scarce to implement every aspect.
First I have to figure out how I can create the option in Codea to have different answers.
Example: How are you today? (a) Great (then the program goes to another menu, silently, with a certain table of conversations). (b) Bad! (the program jumps to another menu with peptalk conversations.
--> to create a believable ai you will have a lot of different menus.
If that succeeds, I even would dare to add some secretary options (like search the web for...), but that is thinking waaaaay up ahead!
It sounds interesting! I think, you'll need random access to different data (or knowledge) bases, in form of tables (instead menus), smartly enough arranged to simulate a "smart" bot. You can start to practice (the acces to tables) with the above given example programs: try modifying the tables "q" and "a" and the access to them ( drawquestion(q[i]) and drawanswer(a[i]) ). By the way, as suggested by dave1707 in a past comment, instead of "if i<3" use "if i<=#q" so it depends on the size of "q" (or "a").
@quezadav
Thank you for the advice! I will try this out tomorrow .
As a dreamy addition: I was actually thinking of making the "Eliza bot" smarter through a conversation.
For example: hey J, what are your hobby's? You answer for example football and on a later stadium she/it answers: "you STILL like football?".
This concept might be possible in c#, but would it be impossible for lua?
Regards
Probably, try saving it as "hobby" and if the next time they answer the same thing (
if answer == readLocalData("hobby") then blah blah end
) you could have it say 'you STILL like'..readData("hobby")