⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ai.cpp.txt

📁 人工智能程序源码
💻 TXT
📖 第 1 页 / 共 2 页
字号:
Date: Wed, 17 Sep 2003 19:03:01 -0700
Here is the AI C++ source code to date. 


********** 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.H
AI.H
SN.H
SE.H
DB.H
AI.CPP
SE.CPP
EN.CPP
DB.CPP
SN.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.H
AI.H
SN.H
SE.H
DB.H
AI.CPP
SE.CPP
EN.CPP
DB.CPP
SN.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.H
AI.H
SN.H
SE.H
DB.H
AI.CPP
SE.CPP
EN.CPP
DB.CPP
SN.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.H
AI.H
SN.H
SE.H
DB.H
AI.CPP
SE.CPP
EN.CPP
DB.CPP
SN.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.H
AI.H
SN.H
SE.H
DB.H
AI.CPP
SE.CPP
EN.CPP
DB.CPP
SN.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.H
AI.H
SN.H
SE.H
DB.H
AI.CPP
SE.CPP
EN.CPP
DB.CPP
SN.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.H
AI.H
SN.H
SE.H
DB.H
AI.CPP
SE.CPP
EN.CPP
DB.CPP
SN.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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -