// truc.cpp : Defines the entry point for the console application.
//
#include "CAssocMem.h"
#include "stdafx.h"
#include <iostream.h>
#include <conio.h>
void myprint(int* tmp)
{
unsigned long cpt;
for (cpt = 0; cpt<64; cpt++)
{
if ((cpt % 8) == 0) cout << endl;
if (tmp[cpt] == 0) cout << ' ';
else cout << '*';
}
cout << endl;
}
int main(int argc, char* argv[])
{
int * set[2];
int pattern1[64] = {0,0,0,0,0,0,0,0,
0,1,1,1,1,1,1,0,
0,1,0,0,0,0,1,0,
0,1,0,0,0,0,1,0,
0,1,0,0,0,0,1,0,
0,1,0,0,0,0,1,0,
0,1,1,1,1,1,1,0,
0,0,0,0,0,0,0,0};
int pattern2[64] = {1,0,0,0,0,0,0,1,
0,1,0,0,0,0,1,0,
0,0,1,0,0,1,0,0,
0,0,0,1,1,0,0,0,
0,0,0,1,1,0,0,0,
0,0,1,0,0,1,0,0,
0,1,0,0,0,0,1,0,
1,0,0,0,0,0,0,1};
set[0] = pattern1;
set[1] = pattern2;
CAssocmem truc(64);
truc.Train(set, 2);
cout << "Recognizing:\n";
myprint(set[0]);
cout << "\n and \n";
myprint(set[1]);
cout << "\nPress a key...\n" << endl;
getch();
int berk[64] = {1,0,0,1,0,0,0,1,
0,1,0,0,0,0,1,0,
1,1,1,0,0,1,0,1,
0,0,0,1,1,0,1,0,
0,0,0,1,1,0,0,0,
1,0,1,0,0,1,0,0,
0,1,0,0,0,0,1,0,
1,0,0,0,1,0,0,1};
int berk2[64] = {0,0,1,0,1,0,1,0,
0,1,1,1,1,1,1,1,
1,1,0,0,0,0,1,1,
1,1,0,0,1,0,1,1,
1,1,0,0,0,0,1,0,
0,1,0,1,0,0,1,0,
1,1,1,1,1,1,1,1,
0,0,1,0,1,0,1,0};
cout << "Oh, my God, an ugly evil pattern...\n";
myprint(berk);
cout << "\nThere it goes, in fact it is a...\n";
truc.Run(berk);
myprint(truc.Get_Outputs());
cout << "\nPress a key...\n" << endl;
getch();
cout << "Oh, my God, yet another ugly evil pattern\n";
myprint(berk2);
cout << "\nAH! recognized you...\n";
truc.Run(berk2);
myprint(truc.Get_Outputs());
cout << "Hooray for the associative memory\nContact me: Atma samchan@club-internet.fr\n";
cout << "Heavily inspired by the tuts at www.generation5.org\n";
return 0;
}
|