My AI Projects

What is Intelligence?

Multiple Intelligences


On Monday I learned there's more than one way to be intelligent! According to Howard Gardner's 1983 book "Multiple Intelligences," there are 9 different "intelligences": logical-mathematical (the traditional math and logic intelligence), bodily-kinaesthetic (control of one's bodily motions), musical, intrapersonal (knowing yourself), verbal-linguistic (a facility with words and languages), naturalistic (skill with plants and animals), existential (religious or philosophical), visual-spatial (the ability to visualize in your mind), and interpersonal (sensitivity to others).

The History of AI


Thousands of years ago the Ancient Greeks and Chinese had legends of humans creating artificial life. Mary Shelley's Frankenstein is the most memorable European story of creating an artificial human.

20th Century

Alan Turing


Alan Turing was a British mathematician and code-breaking hero in WWII. After the war he wrote influential academic papers about computers. One paper proposed a test (now called "The Turing Test") of how realistic a computer program could imitate a human being.

The Turing Machine

As computers developed calculating power which surpassed human abilities, humans once again began to dream of making an artificial human.



A Turing machine is a hypothetical device that manipulates symbols on a strip of tape according to a table of rules. In the 1950s the Turing Machine idea suggested all mathematical reasoning could be done with the symbols computers could easily manipulate (0's and 1's). Computer scientists started to wonder if all human intelligence could be copied by machines.

The Turing Test


In a 1950 paper Alan Turing asked whether computers could successfully imitate humans. This led to the "test" of a computer's intelligence being whether it could respond to questions and make the questioner think a human was answering the questions.

Since then computer programs like ELIZA have passed Turing Tests and there is even a competition to test chatbots for conversational intelligence, the winner receiving the Loebner Prize.

Blade Runner


My vote for AI Movie to Watch is Blade Runner. Based on a book by paranoid sci-fi author Philip K. Dick, the movie Blade Runner raised a lot of questions about how Artificial Intelligence and Robotics might combine in the future to make the Turing test very difficult. In the future, androids (called "replicants") are made of human parts, so it's not easy to tell them from humans. Replicants are used as slaves on other planets, and they have a limited lifespan of 4 years. Some violent replicants have escaped and return to Earth to try to get their creator to prolong their lives. The hero, Rick Deckard, must "retire" them before they kill more humans.

In the movie the equivalent of the Turing test is a battery of questions designed to provoke emotions in the subject that would indicate they're human. But in the beginning a replicant gets so angry at the mention of his "mother" that he kills the examiner. Apparently the replicants have done some "Machine Learning" and have developed their own forms of emotion.

Other Personalities in the History of AI

John McCarthy was a computer scientist who contributed greatly to the development of AI. (He even coined the term in 1955). While at MIT he developed LISP, which for years was considered the programming language of choice for AI. In the 1960s he moved to Stanford University, where he started their AI Laboratory.

MIT's Marvin Minsky wrote books on AI, developed Logo turtles with Seymour Papert, and did groundbreaking work on artificial neural networks.

Chatbots

Chatbots are interactive computer programs that have conversations with users through written input and printed output. The first chatbot was ELIZA, published in 1966. Today I chatted with Jabberwacky and ALICE. The conversation with ALICE didn't fool me into thinking I was chatting with a human:


Chess Chatbots

Not only can you get a good game of chess against a computer program these days, you can also chat with the program:

Programming our Own Chatbot

Later we started programming our own chatbots in Python. Our first chatbot used variables, loops and conditionals to answer pretty randomly. A student suggested it ask a question:

Then it would randomly choose whether to say it liked or hated that song.

Yes or No Question

A useful bit of code was the way the chatbot would ask if the user had a question. It'll come in handy for our games (asking if the user wants the first move, replay, etc.)

Word Search

Using conditionals, it checked for the words "love" and "hate" but if the question didn't contain those it just chose from random responses.


To get the chatbot to have a more realistic (less random) conversation, I added around 20 "elifs" with keywords. This is part of that list:


Even after all that, the conversation wasn't very convincing.

Text-to-Speech (TTS)

On Wednesday we downloaded a TTS program, eSpeak, and a Python module, steel, so we could program our chatbot to "speak" its responses. I had to import steel and declare all the TTS stuff at the beginning of the program, but then all I had to do was type engine.speak("... and it would say the response. The room got pretty loud!
Finally I got the program to take the user's name as input and add the name to a string, then say the whole string. Here's the code:

The Smartest Machine on Earth



Before lunch we watched the Nova episode on Watson, the Jeopardy playing computer. I was interested to see how much more work it would take to go from my simple question-answering program to a Jeopardy Champion. I learned that Watson doesn't do Speech-to-text, it gets the questions texted to it as the humans are listening to the host read them. It was interesting to see all the mistakes Watson and its team made. Machine learning was the key to narrowing down all the possible answers the database search produced, and throwing out the bad responses.

Another interesting thing about the show was that there's things about human intelligence we never knew until we tried to get a computer to do them. The example they used was character recognition. It's easy for us humans to recognize an "A," even if it's in different fonts or handwritten. Computers find it very difficult to recognize different A's!

AI Part Deux

Rock Paper Scissors

Week 7 started with reviewing important Python stuff like loops and lists and variables! Then we created a Rock, Paper Scissors game. I kept running mine at every step but I still got error messages. I was trying to be fancy and import a "replay" module but kept getting messages like "replay not found" and "break outside loop" so I just kept the replay code I had before. Here's the output of an "RPS" game:

With Functions

Functions are a way to help organize your code. They're going to come in handy for the more complicated games we create. Here's how my code looks with functions:


Number Guessing Game

On Tuesday we created a Python program for a number guessing game. We started off my listing all the functions we'd need:


The "greet" function is identical to what we used yesterday. The "computerChoice" function is similar to yesterday's program, too. The difference is it doesn't choose a random element in a list, it chooses a random number from a range:


The "human" function is similar to yesterday's Rock Paper Scissors game, but instead of asking for a letter it asks for a number. Little did we realize this difference would cause problems!


Next we have to compare the number the computer chose to the number the human guessed. It's a lot easier than comparing rocks, paper and scissors!


Announcing a winner is self-explanatory and asking for a replay is identical to yesterday's game. The while loop for the game is here:


We thought we had done everything right, but testing it proved there was something wrong:


I checked the "computer" number and the human number and found out they were different types:


To return a number, we had to change the humanNumber function so it would change the user input to an integer:

Hangman

On Wednesday we started creating a Python program to play Hangman. It's an easy game but as always it's hard to teach a computer to do easy things. Good thing many of the functions we used in previous games came up again:


Before first break I tried to define all the functions and get it to work, but it didn't quite work right:


After break it was debug, debug, debug and look at my functions. Getting the computer to choose from a list of words was identical to getting it to choose between "r" "p" and "s" on Monday:


Here's the print board function, using a list index:


Getting a guess from the user was identical to the previous two games we've done, too:


Now everything should be just a matter of calling the functions from the game loop:

Accessing the web for a list of words

On Thursday I was ready to use a longer list of words, but I didn't want to have to type in hundreds of words myself. There are always ways to do things in Python! We learned to use the urllib module in Python to get a list from the web. We imported the module at the beginning of the program:

And later in the program when choosing the word, this code would be executed:

That way the program could choose at random from a longer list of words. Now I have no idea what word it is!

The Holy Grail of AI: Tic Tac Toe

On Thursday we started on our Tic Tac Toe game. I looked around the web for "Python Tic Tac Toe" to get ideas on how to do it. I saw some good examples and some bad ones. The first file I downloaded and ran didn't tell me how to choose a particular square!



Other programs used code I hadn't learned yet. I couldn't understand some of "Captain DeadBones'" code, for example the "check_win" function:



So I started writing my own functions. My first idea for a "checkWin" function contained a lot of if-statements and returns:


I figured there had to be an easier way. So I looked at the Tic Tac Toe code on Al Sweigart's website. His "isWinner" function looked more compact and I could tell what he was doing. He uses a bunch of "or" statements like this:



I also used Al's idea of creating a list of 10 spaces so we could use the numbers 1 - 9 instead of 0 - 8:


Finally, my printBoard function is similar to Al's:






Home