loading

this is is an instructable that will teach you how to make a python AI.(for real!!!!!!!!!!!)

Step 1: Programing Your AI

here is how to make him. first you have to import random then add different speech categories. like greetings or questions. later you can add categories to your software but for now you will have three. then put while True:

userinput = raw_input is very important so it takes what you put in and only what you put in. The rest is simple, all that you have to do is put: if userInput in greetings:

random_greetings = random.choice(greetings)

print(random_greeting)

to do the other stuff like the questions, all that you have to do is put elif instead of if.

if you are confused the picture at the top might help you.

<p>what version of python is this?</p>
<p>I think they've used Python 2.7. In 3.5, the method to take user input is input() rather than raw_input().</p>
<p>This is so cool.</p><p>import random</p><p>greetings = ['hola','hello','hi','Hi','hey!','hey','sup','whats up?',]</p><p>questions = ['how are you?','how are you doing?']</p><p>responses = ['Okay',&quot;I'm fine&quot; 'i am great!']</p><p>while True:</p><p> userInput = raw_input(&quot;&gt;&gt;&gt; &quot;)</p><p> if userInput in greetings:</p><p> random_greetings = random.choice(greetings)</p><p> print(random_greeting)</p><p> elif userInput in question:</p><p> random_response = random.choice(responses)</p><p> print(random_response)</p><p> else :</p><p> print(&quot;I did not understand what you said&quot;)</p>
<p>Basic, but I like it; it's good to get you started in the right direction.</p>
<p>it is very basic but i feel some times you need basics to get people to want to do it. </p><p>so what would you like your next step to be build a dictionary of question you can ask with a talking reply and a run bash or shell script to do things like open web sits ect... </p>
<p>this is immensly basic. The most basic python algorithm that you can call AI would be tic tac toe or a ping pong game.</p>
<p>thanks</p>
<p>This is great! I'd love to see the output on a screen! </p>

About This Instructable

1,649views

26favorites

License:

More by slade101:real python AI 
Add instructable to: