Date: Wed, 17 Sep 2003 19:03:01 -0700
Here is the AI C++ source code to date.
It is not thoroughly tested and is not
copyright nor warranteed for any use
other than for anyones reference in
connection with an equivalent to
the AI forth code.
********** EN.H file begins *************************************
// Declaration of the EN class. - EnBoot
// Member functions defined in EN.cpp
// For reference only 9/16/03
// preprocessor directives that
// prevent multiple inclusions of header file
#ifndef EN_H
#define EN_H
class EN : public AI { // Initialization of AI arrays (fibers).
public:
EN();
~EN();
void Ena();
void Enb();
static void SetAudData(int t, int pho, int act, int pov,
int beg, int ctu, int psi);
static void SetPsiData(int t, int psi, int act, int jux, int pre,
int pos, int seq, int enx);
static void SetEnData(int t, int nen, int act, int fex,
int pos, int fin, int aud);
private:
};
#endif
****************************** EN.H file ends *******************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** AI.H file begins *************************************
// Declaration of the AI class.
// For reference only 9/16/03
// Member functions defined in AI.cpp
// preprocessor directives that
// prevent multiple inclusions of header file
#ifndef AI_H
#define AI_H
#ifndef TFVAL
#define TFVAL
typedef int BOOL;
static BOOL True = 1;
static BOOL False = 0;
#endif
#ifndef ARY
#define ARY
#define ARYSIZ 100
#endif
#ifndef WRD
#define WRD
#define WRDSIZ 1000
#endif
class AI {
public:
AI(); // Artificial Intelligence Constructor
~AI(); // Artificial Intelligence Deststructor
void Alife(); // Artificial Intelligence Program
protected:
private:
};
class TH : public AI { // Human input module with AI attention
public:
TH();
~TH();
void Thn();
private:
void Activate();
void English();
void NegSvo(); // Negative of Subject-Verb-Object
void Svo(); // Subject Verb-Object
};
class MO : public AI { // Human input module with AI attention
public:
MO();
~MO();
void Mot();
private:
};
#endif
****************************** AI.H file ends *******************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** SN.H file begins *************************************
// Declaration of the SN class.
// Member functions defined in SN.cpp
// For reference only 9/16/03
// preprocessor directives that
// prevent multiple inclusions of header file
#ifndef SN_H
#define SN_H
#define BUFLEN 80
class SN : public AI { // Human input module with AI attention
public:
SN();
~SN();
void Sen();
private:
void Audition();
int AddWrdDb(char * tokenptr);
void AddWrdDbList(char * tokenptr);
void OldConcept();
void NewConcept(int onset);
BOOL AudRecog(char * tokenptr);
void AudDamp();
void RequestMsg();
void ConvUpper();
int ClrSpc(int);
void ClrActTags();
void ClrBuf();
void Parser();
void Activate();
int Find (const char * str, char * s) const;
char Buf[BUFLEN];
};
#endif
****************************** SN.H file ends *******************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** SE.H file begins *************************************
// Declaration of the SE class - Security.
// Member functions defined in SE.cpp
// For reference only 9/16/03
// preprocessor directives that
// prevent multiple inclusions of header file
#ifndef SE_H
#define SE_H
class SE : public AI { // Security = Internal rumination tasks
public:
SE();
~SE();
void Sec();
private:
void Rejuvinate();
void PsiDecay();
void Ego();
};
#endif
****************************** SE.H file ends *******************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** DB.H file begins *************************************
// Declaration of the DB class. Data Base - Fibers
// For reference only 9/16/03
// Member functions defined in DB.cpp
struct AudStr // Auditory Memory Array
{
int pho; // Phoneme
int act; // Activiation Level
int pov; // Point of View
int beg; // Beginning
int ctu; // Continuation
int psi; // Tag number to a concept
};
struct EnStr // English Lexicon Array
{
int nen; // Mindcore concept number
int act; // Activiation Level
int fex; // Mindcor Exit tag
int pos; // Part of Speech
int fin; // Mindcore In tag
int aud; // Auditory Tag
};
struct PsiStr // Mindcore Concept Array
{
int psi; // Mindcore concept number
int act; // Activiation Level
int jux; // Juxtaposed modifier
int pre; // Previous associated
int pos; // Part of Speech
int seq; // Subsequent tag
int enx; // Transfer to English
};
class DB : public AI { // Human input module with AI attention
public:
// set functions
static BOOL SetEle( PsiStr * StrPtr, const int EleIdx); // set concept array element, element index
static BOOL SetEle( EnStr * StrPtr, const int EleIdx); // set english lexicon element, element index
static BOOL SetEle( AudStr * StrPtr, const int EleIdx); // set auditory memory element, element index
// get functions
static PsiStr * GetPsiEle( const int EleIdx); // return concept array element
static EnStr * GetEnEle( const int EleIdx); // return english lexicon element
static AudStr * GetAudEle( const int EleIdx); // return auditory memory element
// delete functions
static BOOL DelPsi( const int EleIdx); // delete concept array element, element index
static BOOL DelEn( const int EleIdx); // delete english lexicon element, element index
static BOOL DelAud( const int EleIdx); // delete auditory memory element, element index
static PsiStr * GetPsiAryPtr();
static EnStr * GetEnAryPtr();
static AudStr * GetAudAryPtr();
static char * GetWrdPtr();
static void PrintMemErr();
static BOOL SetTime(int t);
static int GetTime();
static void StartupMsg();
// print functions
BOOL PrintPsiElements(); // output
BOOL PrintEnElements(); // output
BOOL PrintAudElements(); // output
// Clear data base functions
DB();
~DB();
private:
void Clr();
void ClrPsi(); // Clear Psi array
void ClrEn (); // Clear En array
void ClrAud(); // Clear Aud array
void ClrWrd(); // Clear Word Array
AudStr * AudStrPtr;
EnStr * EnStrPtr;
PsiStr * PsiStrPtr;
};
****************************** DB.H file ends *******************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** AI.CPP file begins ***********************************
// Member function definitions of the AI class.
// For reference only. 9/16/03
#include <iomanip.h>
#include <stdlib.h>
#include <ctype.h>
#include "AI.h"
#include "EN.h"
#include "SE.h"
#include "DB.h"
#include "SN.h"
AI::AI() // Constructor
{
}
AI::~AI() // Destructor
{
}
// Classes below are AI derived classes
MO::MO() // Motorium class constructor
{
}
MO::~MO() // Motorium class destructor
{
}
void MO::Mot() // Motorium
{
}
TH::TH() // Think class constructor
{
} // Think class destructor
TH::~TH()
{
}
void TH::Thn() // Syntax and Vocabulary of Natural Language
{
}
void AI::Alife()
{
DB DatBase; // Create Data Base
EN EngBoot; // Create Initialize Data Base
SE Security; // Create Internal Rumination
SN Sensorium; // Create Human Input Facility
TH Think; // Create Internal Associative Facility
MO Motorium; // Create Output Facility
EngBoot.Ena(); // Initialize Word List
EngBoot.Enb(); // Initialize Word Data Base
DatBase.StartupMsg(); // Display Startup Message
while(True)
{
Security.Sec(); // AI Internal Rumination
Sensorium.Sen(); // AI Initial procesing of Input
Think.Thn(); // AI Syntax and vocabulary of natural language
Motorium.Mot(); // AI Output
};
}
void main(void)
{
AI AI1; // Create Artificial Intelligence Program
AI1.Alife(); // Execute Artificial Intelligence Program
}
****************************** AI.CPP file ends *****************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** SE.CPP file begins ***********************************
// Member function definitions of the SE class.
// For reference only. 9/16/03
#include <iomanip.h>
#include "AI.h"
#include "SE.h"
SE::SE() // Security class constructor
{
}
SE::~SE() // Security class destructor
{
}
void SE::Sec() // Human input module with AI attention
{
Rejuvinate();
PsiDecay();
Ego();
}
void SE::Rejuvinate()
{
}
void SE::PsiDecay()
{
}
void SE::Ego()
{
}
****************************** SE.CPP file ends *****************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** EN.CPP file begins ***********************************
// Member function definitions of the EN class.
// For reference only. 9/16/03
// Enboot - Initialize the memory threads
// with English words
// Definitions:
// Pho - Phoneme
// Act - Flag for previous character hit in search
// Pov - Point of View (# Internal, * External)
// Beg - Beginning of word flag
// Ctu - Continuation of word flag
// Psi - Assoctiaon tag to En Array
// Jux - Juxtaposed word tag
// Pre - Previous concept asssociated with another concept
// Pos - Part of Speech 1=adj 2=adv 3=conj 4=interj 5=noun 6=prep 7=pron 8=verb
// Seq - Subsequent concept associated with another concept
// Enx - Transfer to English
// Nen - English lexical concept number
// Fex - Fiber exit flag
// Fin - Fiber in flag
// Aud - Auditory recall tag
// Psi Concept Numbers
// Articles
// 1 = a,an 2 = all 3 = any 4 = false
// 5 = no 6 = one 7 = the 8 = true
// Adverbs
// 9 = also 10 = else 11 = how 12 = not
// 13 = then 14 = when 15 = where 16 = why
// Conjunctions
// 17 = and 18 = because 19 = either 20 = if
// 21 = or 22 = that 23 = when 24 = whether
// Interjections
// 25 = goodbye 26 = hello 27 = no 28 = no
// 29 = ouch 30 = please 31 = thanks 32 = yes
// Nouns
// 33 = Andru 34 = bugs 35 = cats 36 = fish
// 37 = people 38 = persons 39 = robots 40 = things
// Prepositions
// 41 = at 42 = for 43 = from 44 = in
// 45 = of 46 = on 47 = to 48 = with
// Pronouns
// 49 = he,she 50 = nothing 51 = nothing 52 = they
// 53 = we 54 = what 55 = who 56 = you
// Verbs
// 57 = am,is,are 58 = be 59 = do 60 = hear
// 61 = know 62 = see 63 = think 64 = understand
#include "AI.h"
#include "EN.h"
#include "DB.h"
#include <string.h>
EN::EN()
{
}
EN::~EN()
{
}
// Set data into Aud array (fiber).
void EN::SetAudData( int t, int pho, int act, int pov,
int beg, int ctu, int psi)
{
AudStr AudVal;
AudStr * AudValPtr = &AudVal;
AudVal.pho = pho;
AudVal.act = act;
AudVal.pov = pov;
AudVal.beg = beg;
AudVal.ctu = ctu;
AudVal.psi = psi;
DB::SetEle(AudValPtr,t);
}
// Set data into Psi array (fiber).
void EN::SetPsiData(int t, int psi, int act, int jux, int pre,
int pos, int seq, int enx)
{
PsiStr PsiVal;
PsiStr * PsiValPtr = & PsiVal;
PsiVal.psi = psi;
PsiVal.act = act;
PsiVal.jux = jux;
PsiVal.pre = pre;
PsiVal.pos = pos;
PsiVal.seq = seq;
PsiVal.enx = enx;
DB::SetEle(PsiValPtr,t);
}
// Set data into En array (fiber).
void EN::SetEnData(int t, int nen, int act, int fex,
int pos, int fin, int aud)
{
EnStr EnVal;
EnStr * EnValPtr = & EnVal;
EnVal.nen = nen;
EnVal.act = act;
EnVal.fex = fex;
EnVal.pos = pos;
EnVal.fin = fin;
EnVal.aud = aud;
DB::SetEle(EnValPtr,t);
}
// Initialize arrays (fibers)
void EN::Enb()
{
SetAudData(1,'Y',0,35,1,0,0);
SetAudData(2,'E',0,35,0,1,0);
SetAudData(3,'S',0,35,0,1,0);
SetPsiData(3,32,0,0,0,4,0,32);
SetEnData(3,32,0,32,4,32,1);
SetAudData(5,'I',0,35,1,0,0);
SetAudData(6,'F',0,35,0,1,20);
SetPsiData(6,20,0,0,0,3,0,20);
SetEnData(6,20,0,20,3,20,5);
SetAudData(8,'T',0,35,1,0,0);
SetAudData(9,'H',0,35,0,1,0);
SetAudData(10,'E',0,35,0,1,7);
SetPsiData(10,7,0,0,0,1,0,7);
SetEnData(10,7,0,7,1,7,8);
SetAudData(12,'T',0,35,1,0,0);
SetAudData(13,'R',0,35,0,1,0);
SetAudData(14,'U',0,35,0,1,0);
SetAudData(15,'T',0,35,0,1,0);
SetAudData(16,'H',0,35,0,1,68);
SetPsiData(16,68,0,0,0,5,66,68);
SetEnData(16,68,0,68,5,68,12);
SetAudData(18,'I',0,35,1,0,0);
SetAudData(19,'S',0,35,0,1,66);
SetPsiData(19,66,0,0,68,8,1,66);
SetEnData(19,66,0,66,8,66,18);
SetAudData(21,'T',0,35,1,0,0);
SetAudData(22,'H',0,35,0,1,0);
SetAudData(23,'A',0,35,0,1,0);
SetAudData(24,'T',0,35,0,1,22);
SetPsiData(24,22,0,0,0,3,0,22);
SetEnData(24,22,0,22,3,22,21);
SetAudData(26,'A',0,35,1,0,0);
SetAudData(27,'L',0,35,0,1,0);
SetAudData(28,'L',0,35,0,1,2);
SetPsiData(28,2,0,0,0,1,0,2);
SetEnData(28,2,0,2,1,2,26);
SetAudData(30,'R',0,35,1,0,0);
SetAudData(31,'O',0,35,0,1,0);
SetAudData(32,'B',0,35,0,1,0);
SetAudData(33,'O',0,35,0,1,0);
SetAudData(34,'T',0,35,0,1,0);
SetAudData(35,'S',0,35,0,1,39);
SetPsiData(35,39,0,0,0,5,0,39);
SetEnData(35,39,0,39,5,39,30);
SetAudData(37,'A',0,35,1,0,0);
SetAudData(38,'R',0,35,0,1,0);
SetAudData(39,'E',0,35,0,0,67);
SetPsiData(39,67,0,0,39,8,38,67);
SetEnData(39,67,0,67,8,67,37);
SetAudData(41,'P',0,35,1,0,0);
SetAudData(42,'E',0,35,0,1,0);
SetAudData(43,'R',0,35,0,1,0);
SetAudData(44,'S',0,35,0,1,0);
SetAudData(45,'O',0,35,0,1,0);
SetAudData(46,'N',0,35,0,1,0);
SetAudData(47,'S',0,35,0,0,38);
SetPsiData(47,38,0,0,0,5,0,39);
SetEnData(47,38,0,38,5,38,41);
DB::SetTime(47);
}
// Initialize the word search list
void EN::Ena()
{
char * WrdPtr;
char string[] = " YES IF THE TRUTH IS THAT ROBOTS ";
WrdPtr = DB::GetWrdPtr();
strcpy(WrdPtr,string);
}
****************************** EN.CPP file ends *****************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** DB.CPP file begins ***********************************
// Member function definitions of the DB class.
// For reference only. 9/16/03
// Data Base - Creates and manipulates AI
// memory arrays. Currently 1 dimensional
// fixed length. Should be variable length
// and a linked list to allow convenient
// insertion and deletion. Deletion
// currently just clears the location.
// Should also be asociative memory.
// Hashing would help.
#include <iomanip.h>
#include "AI.h"
#include "DB.h"
int Time; // Time index to words
PsiStr * PsiAryPtr; // Pointer to start of Psi array (fiber).
EnStr * EnAryPtr; // Pointer to start of En array (fiber).
AudStr * AudAryPtr; // Pointer to start of Aud array (fiber).
char * WrdAryPtr; // Pointer to start of Word list.
DB::DB()
{
// Use extensible Array class here
// rather than fixed size array
if((PsiAryPtr = new PsiStr[ARYSIZ]) == (PsiStr *)0)
PrintMemErr();
if((EnAryPtr = new EnStr[ARYSIZ]) == (EnStr *)0)
PrintMemErr();
if((AudAryPtr = new AudStr[ARYSIZ]) == (AudStr *)0)
PrintMemErr();
ClrPsi(); // Clears Psi array (Tabulrasa equivalent)
ClrEn(); // Clears En array (Tabulrasa equivalent)
ClrAud(); // Clears Aud array (Tabulrasa equivalent)
if((WrdAryPtr = new char[WRDSIZ]) == (char *)0)
PrintMemErr();
ClrWrd(); // Clears Word List
}
DB::~DB()
{
delete [] PsiAryPtr;
delete [] EnAryPtr;
delete [] AudAryPtr;
delete [] WrdAryPtr;
}
PsiStr * DB::GetPsiAryPtr() // Get Psi beginning pointer
{
return(PsiAryPtr);
}
EnStr * DB::GetEnAryPtr() // Get En beginning pointer
{
return(EnAryPtr);
}
AudStr * DB::GetAudAryPtr() // Get Aud beginning pointer
{
return(AudAryPtr);
}
char * DB::GetWrdPtr() // Get word list beginning pointer
{
return(WrdAryPtr);
}
void DB::PrintMemErr() // Memory error message
{
cout << "\nArray creation error\n";
}
// Set functions
// Templates to be used for data base functions
BOOL DB::SetEle(PsiStr * StrPtr, const int EleIdx) // Set concept array element
{ // This is the Instantiate module
(PsiAryPtr+EleIdx)->psi = StrPtr->psi;
(PsiAryPtr+EleIdx)->act = StrPtr->act;
(PsiAryPtr+EleIdx)->jux = StrPtr->jux;
(PsiAryPtr+EleIdx)->pre = StrPtr->pre;
(PsiAryPtr+EleIdx)->pos = StrPtr->pos;
(PsiAryPtr+EleIdx)->seq = StrPtr->seq;
(PsiAryPtr+EleIdx)->enx = StrPtr->enx;
return(True);
}
BOOL DB::SetEle(EnStr * StrPtr, const int EleIdx) // set english lexicon element, element index
{ // This is the EnVocab module
(EnAryPtr+EleIdx)->nen = StrPtr->nen;
(EnAryPtr+EleIdx)->act = StrPtr->act;
(EnAryPtr+EleIdx)->fex = StrPtr->fex;
(EnAryPtr+EleIdx)->pos = StrPtr->pos;
(EnAryPtr+EleIdx)->fin = StrPtr->fin;
(EnAryPtr+EleIdx)->aud = StrPtr->aud;
return(True);
}
BOOL DB::SetEle(AudStr * StrPtr, const int EleIdx) // set auditory memory element, element index
{
(AudAryPtr+EleIdx)->pho = StrPtr->pho;
(AudAryPtr+EleIdx)->act = StrPtr->act;
(AudAryPtr+EleIdx)->pov = StrPtr->pov;
(AudAryPtr+EleIdx)->beg = StrPtr->beg;
(AudAryPtr+EleIdx)->ctu = StrPtr->ctu;
(AudAryPtr+EleIdx)->psi = StrPtr->psi;
return(True);
}
// get functions
PsiStr * DB::GetPsiEle( const int EleIdx) // return concept array element
{
return(GetPsiAryPtr() + EleIdx);
}
EnStr * DB::GetEnEle( const int EleIdx) // return english lexicon element
{
return(GetEnAryPtr() + EleIdx);
}
AudStr * DB::GetAudEle( const int EleIdx) // return auditory memory element
{
return(GetAudAryPtr() + EleIdx);
}
// delete functions
BOOL DB::DelPsi( const int EleIdx); // delete concept array element, element index
BOOL DB::DelEn( const int EleIdx); // delete english lexicon element, element index
BOOL DB::DelAud( const int EleIdx); // delete auditory memory element, element index
// print functions
BOOL DB::PrintPsiElements(); // output
BOOL DB::PrintEnElements(); // output
BOOL DB::PrintAudElements(); // output
BOOL DB::SetTime(int t) // Set Time
{
if((t < 65000) && (t >= 0))
{
Time = t;
return(True);
}
else
return(False);
}
int DB::GetTime() // Get Time
{
return(Time);
}
void DB::StartupMsg()
{
cout << "\nThis software is not waranteed to perform any function.\n" << endl;
}
void DB::ClrPsi() // Clears Psi array (Tabulrasa equivalent)
{
int i;
PsiStr PsiZer;
PsiStr * PsiZerPtr = & PsiZer;
PsiZer.psi = 0;
PsiZer.act = 0;
PsiZer.jux = 0;
PsiZer.pre = 0;
PsiZer.pos = 0;
PsiZer.seq = 0;
PsiZer.enx = 0;
for( i=0;i<ARYSIZ;i++)
DB::SetEle(PsiZerPtr,i); ;
}
void DB::ClrEn() // Clears En array (Tabulrasa equivalent)
{
int i;
EnStr EnZer;
EnStr * EnZerPtr = & EnZer;
EnZer.nen = 0;
EnZer.act = 0;
EnZer.fex = 0;
EnZer.pos = 0;
EnZer.fin = 0;
EnZer.aud = 0;
for( i=0;i<ARYSIZ;i++)
DB::SetEle(EnZerPtr,i);
}
void DB::ClrAud() // Clears Aud array (Tabulrasa equivalent)
{
int i;
AudStr AudZer;
AudStr * AudZerPtr = & AudZer;
AudZer.pho = ' ';
AudZer.act = 0;
AudZer.pov = 0;
AudZer.beg = 0;
AudZer.ctu = 0;
AudZer.psi = 0;
for( i=0;i<ARYSIZ;i++)
DB::SetEle(AudZerPtr,i); ;
}
void DB::ClrWrd() // Clears word list
{
int i;
for(i=0;i<WRDSIZ;i++)
*(WrdAryPtr + i) = ' ';
}
****************************** DB.CPP file ends *****************
EN.HAI.HSN.HSE.HDB.HAI.CPPSE.CPPEN.CPPDB.CPPSN.CPP
********** SN.CPP file begins ***********************************
// Member function definitions of the SN class.
// Sensorium - For reference only. 9/16/03
#include <iomanip.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "AI.h"
#include "SN.h"
#include "DB.h"
#include "EN.h"
SN::SN() // Sensorium class constructor
{
} // Sensorium class destructor
SN::~SN()
{
}
void SN::Sen() // Human input module with AI attention
{
RequestMsg(); // Get Human Input
ClrActTags(); // Clear Active Tags
Audition(); // Process Human Input
}
void SN::RequestMsg() // Get Human Input
{
cout << "Enter a brief positive or negative unpunctuated sentence." << endl;
cout << "The AI listens for an input, and then generates a thought.\n" << endl;
cout << "Enter an * to exit the AI.\n" << endl;
cout << "Human: ";
ClrBuf();
cin.getline(Buf,BUFLEN,'\n');
}
void SN::ClrActTags()
{
AudStr * AudPtr;
int t = DB::GetTime();
for (int i = 0;iact = 0;
}
}
void SN::Audition() // AI attention
{
int idx = 0;
int onset; // Beginning of word
char * tokenptr;
if(Buf[0] == '*') // If first character is * then exit program
{
cout << "\nUser Halt.\n" << endl;
exit(0);
}
ConvUpper(); // Convert all characters in message to upper case
idx = ClrSpc(idx); // Skip any leading spaces in messge
// Process words and characters by propagating effect of old
// words into Psi data base and adding new words and propagating
// their presence into the Psi data base.
tokenptr = strtok(Buf," ");
tokenptr = tokenptr + idx; // Adjust pointer to skip leading spaces
while(tokenptr != NULL) // Extract words
{
cout << tokenptr << endl;
if(AudRecog(tokenptr)) // Test for word in data base list
{
OldConcept(); // Word is in data base so update concept
}
else
{
onset = AddWrdDb(tokenptr); // Add word to data base and return start time
AddWrdDbList(tokenptr); // Add word to data base list
NewConcept(onset); // Update concept of new word
}
tokenptr = strtok(NULL, " ");
}
}
// Find the index to the first character of the
// character string str embedded in the character
// string s.
int SN::Find (const char * str, char * s) const
{
char * s2 = strstr(s,str);
if (s2)
return (s2 - s);
else
return(-1);
}
void SN::ClrBuf() // Clear the input buffer
{
int i = 0;
for(i=0;i<BUFLEN;i++)
Buf[i] = NULL;
}
void SN::ConvUpper() // Convert input to upper case
{
for(int i =0;i<BUFLEN;i++)
Buf[i] = (char) toupper(Buf[i]);
}
int SN::ClrSpc(int i) // Find index for first non space character
{
while(Buf[i] == ' ')
{
i++;
}
return(i);
}
BOOL SN::AudRecog(char * tokenptr) // Test for word in data data base list
{
int i,len;
char * Wrd;
Wrd = DB::GetWrdPtr();
i = SN::Find(tokenptr,Wrd);
if(i<0)
return(False);
if(*(Wrd + i - 1) != ' ')
return(False);
len = strlen(tokenptr);
if(*(Wrd + i + len) != ' ')
return(False);
return(True);
}
void SN::OldConcept() // Update arrays (fibers) for existing word (concept)
{
SN::Parser();
SN::Activate();
}
void SN::NewConcept(int onset) // Update arrays (fibers) for new word (concept)
{
int t;
t = DB::GetTime();
EN::SetPsiData(t,1,31,0,0,5,0,1);
EN::SetEnData(t,1,31,1,5,1,onset);
}
void SN::Parser()
{
}
void SN::Activate()
{
}
int SN::AddWrdDb(char * tokenptr) // Add a word to the Aud array (fiber).
{
int t,i,wrdlen,onset;
wrdlen = strlen(tokenptr);
t = DB::GetTime();
t = t + 2; // Leave blank in data base and set time for new word start
onset = t; // Save the new word start time
EN::SetAudData(t,*(tokenptr),0,35,1,0,0); // Set first letter
if(wrdlen >= 1)
{
for(i=1;i<wrdlen;i++)
{
EN::SetAudData(t,*(tokenptr+i),0,35,0,1,0);
t++;
}
DB::SetTime(t);
}
return(onset);
}
void SN::AddWrdDbList(char * tokenptr) // Add a word to the word search list
{;
char * WrdList;
WrdList = DB::GetWrdPtr();
strcat(WrdList,tokenptr);
strcat(WrdList," ");
}
****************************** SN.CPP file ends *****************
Notes
The source code above from the year 2003 was not finished and
remains incomplete. Meanwhile, an
AI breakthrough occurred on
7 June 2006 in the
Mind.Forth artificial intelligence software.
Because it is easier to see the AI breakthrough in
JavaScript
than in Forth, this page has been modified to open a new window
containing a full-screen instance of the JavaScript
Mind.html tutorial AI.
Terminate the Mind to close the window in which the AI thinks visibly.