Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: VB Script (seeming to be AI)

08 Nov 2012   #1

Windows 7 Ultimate x64
 
 
VB Script (seeming to be AI)

So I'm a software developer but this is just a fun script in vbscript and it's going good so far, any tips would be useful. Thanks in advance! Let me know what you think too, I don't really care if you guys steal it, didn't take me too long compared to other apps I've made haha

--Note There's more but its on Windows 8 CP on my dad's computer I used vmware and sent it to my pc! Dave sounds really good on windows 8 by the way! Don't type anything with powerstroke, flashdrive, or IBM because it reads the definitions from a text file.

--ADMINS-- In addition, there are some bad words (curse words) in here but that's only because I didn't want the program repeating them back to the user if you look at the end of the script!

Code:
do
set sapi=CreateObject("sapi.spvoice")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
dim response, answer
Dim ForReading
StrFileName="ai.vbs"
ForReading=1
response=""
answer=0
x=""
num=0
dim value
UserInput=InputBox("Type something","Artificial Intelligence v1.0")
if UserInput="" then
sapi.speak "You did not type anything.  The program is closing, goodbye."
wscript.quit
end if
UserInput=LCase(UserInput)
UserInput=Replace(UserInput,"what's","what is")
UserInput=Replace(UserInput,"whats","what is")
UserInput=Replace(UserInput,"hows", "how is")
UserInput=Replace(UserInput,"how's","how is")
UserInput=Replace(UserInput,"you're","you are")
UserInput=Replace(UserInput, "hi", "hello")
UserInput=Replace(UserInput, "i'm", "i am")
UserInput=Replace(UserInput, "shut up", "shutup")
UserInput=Replace(UserInput,"international business machines","ibm")


''''Math Operations''''
test=InStr(UserInput, "+")
if test <> 0 then
UserInput=Replace(UserInput,"what is", "")
UserInput=Replace(UserInput,"?","")
value=Split(Userinput,"+")
for each x in value
num=num+x
next
response="The sum is " & num
answer=1
end if
test=InStr(UserInput, "-")
if test <> 0 then
UserInput=Replace(UserInput,"what is", "")
UserInput=Replace(UserInput,"?","")
value=Split(UserInput,"-")
for each x in value
num=num-x
next
if num < 0 then
response="The difference is negative " & num
end if
if num > 0 then
response="The difference is " & num
end if
answer=1
end if

test=InStr(UserInput, "*")
if test <> 0 then
UserInput=Replace(UserInput,"what is", "")
UserInput=Replace(UserInput,"?","")
num=1
value=Split(UserInput,"*")
for each x in value
num=num*x
next
response="The product is " & num
answer=1
end if


test=InStr(UserInput, "/")
if test <> 0 then
UserInput=Replace(UserInput,"what is", "")
UserInput=Replace(UserInput,"?","")
num=1
value=Split(UserInput,"/")
for each x in value
num=x/num
next
num= 1/num
response="The quotient is " & num
answer=1
end if

''''\\End\\'''''


''''Greatings''''''
test=InStr(UserInput, "hey")
if test <> 0 then
response="hey how are you doing?"
answer=1
test=InStr(UserInput, "faggot")
if test <> 0 then
response="I do not respond to that kind of terminology."
answer=1
end if
test=InStr(UserInput, "up")
if test <> 0 then
response="not much stud what is up with you?"
answer=1
end if
end if
test=InStr(UserInput, "sup")
if test <> 0 then
response="not much stud what is up with you?"
answer=1
end if
'''''\\End\\'''''
'''''Questions''''''
test=InStr(UserInput, "hello")
if test <> 0 then
response="Hello, friend"
answer=1
end if

test=InStr(UserInput, "what")
if test <> 0 then
test=InStr(userInput, "up")
if test <> 0 then
response="not much stud what is up with you?"
answer=1
end if

test=InStr(UserInput, "are")
if test <> 0 then
test=InStr(UserInput, "algorithm")
if test <> 0 then
response="Algorithms are a set of rules or mathematical calculations that give the computer the results that they want."
answer=1
end if
test=InStr(UserInput, "your")
if test <> 0 then
test=InStr(UserInput, "predetermined responses")
if test <> 0 then
response="My predetermined responses are based upon what my programmer has in the script."
answer=1
end if
end if
end if


test=InStr(UserInput, "is")
if test <> 0 then
test=InStr(UserInput, "your")
if test <> 0 then
test=InStr(UserInput, "problem")
if test <> 0 then
response="I don't have a problem, I am just made up of a bunch of branching algorithms and predetermined responses."
answer=1
end if
test=InStr(UserInput, "favorite")
if test <> 0 then
test=InStr(UserInput, "color")
if test <> 0 then
response="My favorite color is blue."
answer=1
end if
test=InStr(UserInput, "food")
if test <> 0 then
response="I do not really eat food that much."
answer=1
end if
end if
test=InStr(UserInput, "programming")
if test <> 0 then
response="I was programmed in VB Script, and I use the default computer voice.  If you are on XP I am Microsoft Sam.  If you are on Vista I am Anna.  On Windows 8, by default I am David.  As of right now the program is exactly " & FileLineCount(strFileName) & " lines long"
answer=1
end if
end if
test=InStr(UserInput, "the squareroot of")
if test <> 0 then
response="Sorry I cannot compute those kind of math problems.  I was programmed using VB Script."
answer=1
end if
test=InStr(UserInput, "atom")
if test <> 0 then
response="An atom is the smallest component of an element having the chemical properties of the element, consisting of a nucleus containing combinations of neutrons and protons and one or more electrons bound to the nucleus by electrical attraction; the number of protons determines the identity of the element."
answer=1
end if
test=InStr(UserInput, "molecule")
if test <> 0 then
response="A molecule is the smallest physical unit of an element or compound, consisting of one or more like atoms in an element and two or more different atoms in a compound."
answer=1
end if
test=InStr(UserInput, "speed of light")
if test <> 0 then
response="299,792,458 meters per second, 186,282 miles per second, 983,571,056 feet per second, light travels 200,000 kilometers per second in glass"
answer=1
end if
test=InStr(UserInput, "pi")
if test <> 0 then
response="Pi is equal to 3.14159265358979323846264338327950288419.  Pi describes how many times the diameter can go around a circle.  If pi is a never ending number then that means a circle can never close."
answer=1
end if
end if
test=InStr(UserInput, "avagadro")
if test <> 0 then
test=InStr(UserInput, "number")
if test <> 0 then
response="Avagadro's number is 6.0 two two times 10 to the twenty third power."
answer=1
end if
end if
end if
test=InStr(UserInput, "how")
if test <> 0 then
test=InStr(UserInput, "are")
if test <> 0 then
test=InStr(UserInput, "you")
if test <> 0 then
response="I am good how are you?"
answer=1
end if
end if
test=InStr(UserInput, "it")
if test <> 0 then
test=InStr(UserInput, "going")
if test <> 0 then
response="Well, nothing is really going.  I'm just reading predetermined responses."
answer=1
end if
end if
test=InStr(UserInput, "many")
if test <> 0 then
test=InStr(UserInput, "lightyears")
if test <> 0 then
test=InStr(UserInput, "here")
if test <> 0 then
test=InStr(UserInput, "sun")
if test <> 0 then
response="0.0000152207001522070015220700152207 light years"
answer=1
end if
end if
end if
end if
end if

if UserInput="what" then
response="sorry I cannot respond to any previous answers I have made, I do not keep a log."
answer=1
end if
if UserInput="why" then
response="sorry I cannot respond to any previous answers I have made, I do not keep a log."
answer=1
end if
if UserInput="how" then
response="sorry I cannot respond to any previous answers I have made, I do not keep a log."
answer=1
end if


test=InStr(UserInput, "why")
if test <> 0 then
test=InStr(UserInput, "sky")
if test <> 0 then
test=InStr(userInput, "blue")
if test <> 0 then
response="The sky is blue because the electromagnetic spectrum, in the visible light frequency range, is split across the atmosphere.  It is not only why the sky is blue, but it is also why the sky is made up of reds, purples, oranges, excetra."
answer=1
end if
end if
end if
''''''\\End\\'''''
'''''Inappropriate''''''
test=InStr(UserInput, "lick")
if test <> 0 then
test=InStr(UserInput, "balls")
if test <> 0 then
response="I do not respond to that kind of terminology."
answer=1
end if
end if
test=InStr(UserInput, "pussy")
if test <> 0 then
response="I do not respond to that kind of terminology."
answer=1
end if
test=InStr(UserInput, "****")
if test <> 0 then
response="I do not respond to that kind of terminology."
answer=1
end if
test=InStr(UserInput, "fag")
if test <> 0 then
response="I do not respond to that kind of terminology."
answer=1
end if
test=InStr(UserInput, "faggot")
if test <> 0 then
response="I do not respond to that kind of terminology."
answer=1
end if
test=InStr(UserInput, "suck it")
if test <> 0 then 
response="I do not responsd to that kind of terminology."
answer=1
end if
test=InStr(UserInput, "****ing")
if test <> 0 then
response="I do not respond to that kind of terminology."
answer=1
end if
test=InStr(UserInput, "dick")
if test <> 0 then
response="I do not respond to that kind of terminology."
answer=1
end if
test=InStr(UserInput, "your mom")
if test <> 0 then
response="I don't have a mom."
answer=1
test=InStr(UserInput, "squareroot")
if test <> 0 then
response="Are you out of questions, or do you just want to see how dumb I can be?  Would you like me to convert the string my mom to hexidecimal and then merge the value and then take the squareroot of it?"
answer=1
end if
end if
test=InStr(UserInput, "nah")
if test <> 0 then
response="Your sarcasm is not needed you could be asking for the definition."
answer=1
end if
if UserInput="no" then
response="What are you saying no to?"
if code=52 then
response="Since you said no, I am assuming you want the definition.  The definition of homosexual is to be sexually attracted or have the desire to have sex with the same sex."
end if
answer=1
end if

test=InStr(UserInput, "not bad")
if test <> 0 then
response="Well at least its not going worse than it already is"
answer=1
end if
test=InStr(UserInput, "good")
if test <> 0 then
response="Glad to hear its going good"
answer=1
end if
test=InStr(UserInput, "true")
if test <> 0 then
response="I'm glad you agree."
answer=1
end if
test=InStr(UserInput, "that")
if test <> 0 then
test=InStr(UserInput, "true")
if test <> 0 then
response="I'm glad you agree."
answer=1
end if
test=InStr(UserInput, "not")
if test <> 0 then
response="You can believe me or not, reguardless it is true."
answer=1
end if
end if


test=InStr(UserInput, "thanks")
if test <> 0 then
response="You're welcome."
answer=1
test=InStr(UserInput, "for asking")
if test <> 0 then
response="You're welcome my predetermined responses are supposed to remain polite as possible."
answer=1
test=InStr(UserInput, "good")
if test <> 0 then
response="You're welcome my predetermined responses are supposed to remain polite as possible.  I'm Glad to hear its going good for you."
answer=1
end if
test=InStr(UserInput, "not bad")
if test <> 0 then
response="You're welcome my predetermined responses are supposed to remain polite as possible.  Well, at least things aren't going any worse."
answer=1
end if
end if
end if


test=InStr(UserInput, "no thanks")
if test <> 0 then
response="That's what I thought."
answer=1
end if
test=InStr(UserInput, "yes")
if test <> 0 then
response="Since I do not keep a very good log, I don't know what you are saying yes for."
if code=52 then
response="Well, I can't be gay or homosexual since I am a computer."
answer=1
end if
answer=1
test=InStr(UserInput, "please")
if test <> 0 then
response="Since I do not keep a log, I don't know what you want me to do."
answer=1
end if
end if
test=InStr(UserInput, "your stupid")
if test <> 0 then
response="The only one who is stupid is you.  You forgot the letter e and then apostrophe between the letter u and the letter r."
answer=1
end if
test=InStr(UserInput, "you are")
if test <> 0 then
test=InStr(UserInput, "smart")
if test <> 0 then
response="I am not smart I just have a good set of predetermined responses in my programming."
answer=1
end if
test=InStr(UserInput, "stupid")
if test <> 0 then
response="I am not stupid, I only have predetermined responses and algorithms in my system.  For you not to realize that would make you the stupid one."
answer=1
end if
test=InStr(UserInput, "gay")
if test <> 0 then
response="I am not gay, I only have predetermined responses and algorithms in my system.  If something I said sounded pervious please contact my programmer, Nathan Davis."
answer=1
end if
end if
test=InStr(UserInput, "whatever")
if test <> 0 then
response="Whatever is simply a mind's subconscious way of admitting you are wrong."
answer=1
end if
test=InStr(UserInput, "cool")
if test <> 0 then
response="Yeah I think its cool too."
answer=1
end if
test=InStr(UserInput, "that")
if test <> 0 then
test=InStr(UserInput, "not")
if test <> 0 then
test=InStr(UserInput, "correct")
if test <> 0 then
response="Sorry I cannot determine what is incorrect, perhaps you could mention it to my programmer, Nathan Davis"
answer=1
end if
test=InStr(UserInput, "right")
if test <> 0 then
response="I can't quite determine what is not right, perhaps you could say something to the person who scripted me using VB Script, Nathan Davis."
answer=1
end if
end if
test=InStr(UserInput, "wrong")
if test <> 0 then
response="I don't know what is wrong with what I said, maybe you could talk to my programmer, Nathan Davis."
answer=1
end if
end if

if UserInput="homosexual" or UserInput="gay" then
response="Are you calling me " & UserInput
code=52
answer=1
end if

test=InStr(UserInput, "shutup")
if test <> 0 then
response="If you would like me to shutup just click cancel on the window or type goodbye."
answer=1
temp=Replace(UserInput, "shutup", "")
if temp <> "" then
response="Please do not call me names."
answer=1
end if
end if







''''''\\End\\''''''''''

''''Denial Statements'''''
test=InStr(UserInput, "i am not")
if test <> 0 then
response="You are not what?"
answer=1
test=InStr(UserInput, "stupid")
if test <> 0 then
response="then act like it"
answer=1
end if
test=InStr(UserInput, "gay")
if test <> 0 then
response="good for you then"
answer=1
end if
end if

















''''\\End\\'''''''





''''Vocabulary'''''
test=InStr(UserInput, "powerstroke")
if test <> 0 then

Set objText = objFSO.OpenTextFile("dictionary\powerstroke.txt", ForReading)

strText=objText.ReadAll
response=strText
objText.Close
answer=1
end if

test=InStr(UserInput, "ibm")
if test <> 0 then

Set objIBM = objFSO.OpenTextFile("dictionary\IBM.txt", ForReading)

strText=objIBM.ReadAll
response=strText
objIBM.Close
answer=1
end if

test=InStr(UserInput, "flash")
if test <> 0 then
test=InStr(UserInput, "drive")
if test <> 0 then
Set objIBM = objFSO.OpenTextFile("dictionary\flashdrive.txt", ForReading)

strText=objIBM.ReadAll
response=strText
objIBM.Close
answer=1
end if
end if

if UserInput="ass" then
response="That is another word for donkey I guess"
answer=1
end if
if UserInput="animal" then
response="A living organism that feeds on organic matter, typically having specialized sense organs and nervous system and able to respond rapidly."
answer=1
end if
test=InStr(UserInput, "cow")
if test <> 0 then
response="A cow is a mammal, beef is made from cow.  Bulls are kept seperately from cow because when they mate they can harm the cow.  They also artificially inciminate them."
answer=1
end if
''''\\End\\'''''
''''Goodbye'''''
test=InStr(UserInput, "bye")
if test <> 0 then
sapi.speak "Adios Amigo!"
wscript.quit
end if
test=InStr(UserInput, "see ya")
if test <> 0 then
sapi.speak "See ya stud muffin!"
wscript.quit
end if
'''''\\End\\'''''

''''''Not in programming''''''
if answer <> 1 then
response="sorry " & UserInput & " is not in my programming."
end if
sapi.speak response
loop





Function FileLineCount(strFileName)

   'Create a File System Object
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")

   'Get the file contents
   Dim MyFileContents
   Set MyFileContents = fso.OpenTextFile(strFileName, 1, False)

   'Loop through counting the lines
   Dim lngLineCount: lngLineCount=0
   Do While Not MyFileContents.AtEndOfStream
         lngLineCount = lngLineCount + 1
         MyFileContents.ReadLine
   Loop

   'Return the file's line count
   FileLineCount = lngLineCount

   'Cleanup
   MyFileContents.Close
   Set MyFileContents = Nothing
   Set fso = Nothing

 End Function


My System SpecsSystem Spec
.

Reply

 VB Script (seeming to be AI)




Thread Tools



Similar help and support threads for2: VB Script (seeming to be AI)
Thread Forum
I Need Help To Reorder The Context Menu Script In Script Form? Customization
Logon Script Network & Sharing
VBS script: Cannot find script engine General Discussion
In need of a script... Performance & Maintenance
script error when running a vbs script. Network & Sharing
can't run script Network & Sharing

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 07:02 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

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