Although Pascal is not a mainstream artificial intelligence (AI) language, you can use it to experiment, I for one enjoy Artificial Intelligence. It is an area of programming where no one has been 100% successful as of yet!!. Normally programs that consist of artificial intelligent algorithms, will mainly be built around the existence of a list of information items that can be extended by the program automatically ie "learns" new things just like we do. In a language like LISP, considered to be the main artifical intelligence language, the language itself performs list maintenance with ease. In Pascal you have to program such procedures by using linked and dynamic allocation, sounds complicated... Not really, if you understand pointers, records etc the program structure is not as complex as it sounds.
Although the example here is very simple, the concepts can be applied to more sophisticated "intelligent" programs.
[Click Here To Download The Example Archive - AI.ZIP]
Thank You To Creative Legacies For The User-Interface Improvement!!
What Is It All About?
One area of AI covers programs that seem to behave like people, this seems to be everyones favourite, ZIGGY springs to mind!!. The famous Eliza program, for example, appeared to be a psychiatrist. It would be wonderful to have a computer program that would carry on a conversation about anything, keep dreaming we are a long way away yet, but getting closer. - it would be a great program to run when you were tired of programming and feeling bored as hell!! The program I have done here used is an extremely simple version of
such a program, it is possible to expand on this program to make it more and more sophisticated, and therefore more like a human. It uses words and their definitions to carry on a simple conversation with the user. One device common to many AI programs is the linking of an informational item with its meaning, in this case, the program links words with their meaning, and descriptions. The following record holds each word, its definition, its part of speech, and its connotation.
How The Program Works.
In the program I have generously provided, you enter a word, its definition, the type of word it is, and its connotation of good, bad, or indifferent. To hold these dictionary entries, a linked list is then built, by using dynamic allocation. The procedure DLS_Store creates and maintains a sorted, doubly linked list of the dictionary. After you have entered a few words into the dictionary, you can begin to have a conversation with the computer. For example, you type in a sentance, such as "It is a nice day." The program scans the sentance for a noun that it knows. If it fonds one, it makes a comment about the noun, based on its meaning. If the program encounters a word that it does not know, it prompts you to enter that word with its definition. You type QUIT to exit conversation mode.
The procedure Talk is part of the program that carries on the conversation. A support function called Dissect looks at you input sentence a word at a time. The variable sentance holds you input sentance. Dissect removes a word at a time from sentance and returns it in word. Within the program given here you can find the functions Talk and Dissect.
Well the program its self took me some time to develop, so really I would have loved to have written more about the subject as I really want to develop a high quality artificial intelligent program that could acta as an operating system. Well I can just keep on dreaming!! But neither the less, may be one day....
Now I should think that the example should explain enough to you about how to go ahead with delevoping a better more complex artifical intelligent program. Remember, the program I have written here is only the real basics of writing a top AI system. Heres a few points you should consider if you want to develop this system further. How about making the computer scan your sentance for verbs and then have it substitute an alternative verb in its comment (this will give a much smarter appearence). Or how about getting the system to ask questions?... Its up to you. I have started you off.