2.1 AI C Code on PIC

1. Introduction

1.1 This project is simply a demonstration of how to load up a C program onto the computer-type devices which I built in the projects "Handmade computer on the PIC24fj256.." and the PIC24fj64 (see above).

1.2 It's based on Herbert Schildt's 1987 'Artificial Intelligence Using C' (Osborne McGraw Hill, California, 1987).

1.3 Given a functioning screen and keyboard, with the firmware loaded below onto the PIC24fj64, when typing questions or comments into the keyboard, the screen will output sensible responses.

1.4 Obviously, this is no more than the type of 'AI' developed in the ELIZA program of the late 60's.

1.5 Sometimes called a 'chatbot', this type of AI forms the basis of most contemporary AI. The program scans your input for key words, then outputs relevant responses to those keywords. The responses seem natural and spontaneous only because of the care with which the database of stock replies has been set up. The example here has a database which gives responses carefully imitating the kinds of responses which a psychotherapist would provide.

2. Example

2.1 Because C does not use databases, we provide a set of responses and key words located in an array. Of course, C Code also draws on structures in lieu of database functionality. But structs are not used here.

2.2 Ammend or add to the 'keyword','response' text in the array in order to expand the AI appearance.

2.3 Note the following additional features:

2.3.1 A variety of opening statements meant to ellicit a response from the user

2.3.2 A default statement, 'Tell me more.. ' when the user input something which falls outside the 'if' statements.

2.3.3 Storage of topics or past statements, so that the program can call on these to prompt the user for more, or notice repeitious statements from the user.

2.3.4 A stock response to short or very short inputs from the user.

2.4 Here is a typical exchange which the firmware will output to a user:

How are you this beautiful day?
: I don't know, I feel bad

How do you know that?

: I feel I could kill

It is wrong to kill

: I never seem to win

Don't be negative - be positive!

: Why, are you sure?

Remember, therapy is good for you.

: Why, are you sure?

Stop repeating yourself.

: Hey, who cares jerk

Don't ever call me a jerk!

: I'll call you a jerk any time I want to

Let's not talk about me.

: I am unhappy

Why are you unhappy?

3. Firmware

3.1 The following code has been adapted from the Schild text, with some corrections.

3.2 It will only work with the handmade computer projects, since I have replaced gets() and printf() commands with the proprietary functions to work with the handmade computer.

3.3 Firmware:

Download the C Source files

18. Copyright, Jason Powell, March 2020

Design Jason Powell, 2020.