diff --git a/InterfaceCpp/car.cpp~ b/InterfaceCpp/car.cpp~ deleted file mode 100644 index 2aea251..0000000 --- a/InterfaceCpp/car.cpp~ +++ /dev/null @@ -1,312 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "sdlcommon.h" -#include "car.h" -#include "shmdata.h" - -using namespace std; - -Car::Car() - { - initShm(); - reset(); - showbar=1; - angstep=5; - for(int i=0;iw, voitsurf->h, 32, 0,0,0,0); - if(SDL_SetColorKey(Surface_car[i], SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(Surface_car[i]->format, 255,0,255)) == -1) - fprintf(stderr, "Warning: colorkey will not be used, reason: %s\n", SDL_GetError()); - rotatesurface(voitsurf,Surface_car[i],i); - } - carimage=1; - printf("Done ... (%d ms)\n",SDL_GetTicks()-cur); - } - -void Car::updateCar(SDL_Surface* screen) - { - int i; - for(i=0;(SData->read!=0) && i<200;i++) usleep(5); // on attends 1 seconde - if(i==200) - { - cout << "AutoPilot Timed Out ..."; - exit(0); - } - if(SData->Res[0]) decAngle(); - if(SData->Res[1]) incAngle(); - SData->Res[0]=0; - SData->Res[1]=0; - SData->pos_x+=getSpeed()*(cos(SData->angle*PI/180)); - SData->pos_y+=getSpeed()*(sin(SData->angle*PI/180)); - showTrainee(screen); - showCamera(screen); /* obligé pour avoir les pixels :-) */ - // CAMERASIZE // CAMERASTEP - if(carimage) /* on blit la voiture */ - { - SDL_Rect r; - r.w=Surface_car[SData->angle]->w; - r.h=Surface_car[SData->angle]->h; - r.x=(int)SData->pos_x-(r.w/2); - r.y=(int)SData->pos_y-(r.h/2); - SDL_BlitSurface( Surface_car[SData->angle], NULL, screen, &r); - } - else for(int i=0;i<20;i++) /* affichage de la voiture simplifiée (ligne rouge) */ - { - setpixel(screen,(int)(SData->pos_x-(cos(SData->angle*PI/180)*i)),(int)( SData->pos_y-(sin(SData->angle*PI/180)*i)),255,0,0); - } - for(int i=0;iV[i]=camera[i]; - } - SData->read=1; /* on a lu :D */ - //cout << endl; - } - -void Car::showTrainee(SDL_Surface* screen) - { - int k; - trainee[traineepos][0]=(int)SData->pos_x; - trainee[traineepos][1]=(int)SData->pos_y; - traineepos=(traineepos+1)%traineesize; - k=traineepos; - k=(k+1)%traineesize; - for(int i=0; /*i < traineesize &&*/ k!=traineepos;i++) /* affichage de la trainée */ - { - //setpixel(screen,trainee[k][0],trainee[k][1],0,(int)(i*(256.0/traineesize))%256,255); - int x0,y0,x1,y1; - x0=trainee[(k+traineesize-1)%traineesize][0]; - y0=trainee[(k+traineesize-1)%traineesize][1]; - x1=trainee[k][0]; - y1=trainee[k][1]; - if(x0==0) x0=x1; - if(y0==0) y0=y1; - if(x1==0) x1=x0; - if(y1==0) y1=y0; - DrawLine(screen,x0,y0,x1,y1,0,0,255); - k=(k+1)%traineesize; - } - - } - -void Car::showCamera(SDL_Surface* screen) - { - double x,y; - int k,ang; - x=SData->pos_x + ( cos(SData->angle*PI/180) * CAMERADISTANCE ); - y=SData->pos_y + ( sin(SData->angle*PI/180) * CAMERADISTANCE ); - ang=(SData->angle+90)%360; - x-=CAMERASIZE/2*cos(ang*PI/180); - y-=CAMERASIZE/2*sin(ang*PI/180); - k=0; - for(int i=0;i0 && xw && y>0 && yh) - camera[k]=(((getpixel(screen,(int)x,(int)y))%2)+1)%2; - else camera[k]=0; - - if(camera[k] && showbar) - { - setpixel(screen, (int)x, (int)y,255,0,0); - //setpixel(screen, (int)x, (int)y-1,255,0,0); - //setpixel(screen, (int)x-1, (int)y,255,0,0); - //setpixel(screen, (int)x-1, (int)y-1,255,0,0); - } - else if(showbar) - { - setpixel(screen, (int)x, (int)y,0,255,0); - //setpixel(screen, (int)x, (int)y-1,0,255,0); - //setpixel(screen, (int)x-1, (int)y,0,255,0); - //setpixel(screen, (int)x-1, (int)y-1,0,255,0); - } - k++; - } - else - { - if(showbar) setpixel(screen, (int)x, (int)y,0,0,255); - } - } - } - -void Car::incAngle() - { - SData->angle=(SData->angle+angstep)%360; - } -void Car::decAngle() - { - SData->angle=(SData->angle+360-angstep)%360; - } -int Car::incAngleStep(int i) - { - angstep+=i; - return angstep; - } -void Car::incSpeed() - { - if(SData->Res[2]==0) - { - SData->Res[0]=0; - SData->Res[1]=0; - SData->Res[2]=1; - if(SData->speed==0) SData->speed=1; - } - SData->speed++; - } -void Car::decSpeed() - { - SData->speed--; - } -bool Car::APToggle() - { - SData->APon=(SData->APon+1)%2; - return SData->APon; - } - -bool Car::APState() const - { - return SData->APon; - } -bool Car::neurToggle() - { - SData->Neuron=(SData->Neuron+1)%2; - return SData->Neuron; - } - -bool Car::neurState() const - { - return SData->Neuron; - } -void Car::initShm() - { - if ((shmid = shmget(SHMKEY, sizeof(struct shmdata), 0666)) < 0) - { - perror("shmget"); - exit(1); - } - if (( SData = (struct shmdata *)shmat(shmid, NULL, 0)) == (struct shmdata *) -1) - { - perror("shmat"); - exit(1); - } - } -int Car::getSpeed() const - { - if(SData->Res[2]) - return SData->speed; - return 0; - } -int Car::getAngle() const - { - return SData->angle; - } -bool Car::showBar(int i) - { - showbar=(showbar+i)%2; - return showbar; - } -bool* Car::getVect() - { - return SData->Res; - } -bool* Car::getView() - { - return SData->V; - } -void Car::reset() - { - SData->pos_x=200; - SData->pos_y=200; - SData->speed=1; - SData->angle=0; - SData->Res[2]=1; - } -void Car::turn180() - { - SData->angle=(SData->angle+180)%360; - } -int Car::incTraineeSize(int s) - { - int i,k; - if(s==0) return traineesize; - if(traineesize==1 && s<0) return traineesize; - if(traineesize+s > TRAINEESIZE) s=TRAINEESIZE-traineesize-1; - if(traineesize+s < 0) s=1-TRAINEESIZE; - int tmp[traineesize+s][2]; - k=traineepos; - if(s<0) k=(traineesize+traineepos-s)%traineesize; - for(i=0;i<(traineesize+s);i++) - { - if(i>traineesize) - { - tmp[i][0]=0; - tmp[i][1]=0; - } - else - { - tmp[i][0]=trainee[k][0]; - tmp[i][1]=trainee[k][1]; - } - k=(k+1)%traineesize; - } - for(i=0;idelay=del; - } -void Car::harakiri() - { - cout << " EXIT INTERFACE ...\n"; - SData->read=666; - usleep(100); - SData->read=666; - usleep(100); - SData->read=666; - } -void Car::saveState() - { - SData->action=SAVE_STATE; - } -void Car::loadState() - { - SData->action=RELOAD_STATE; - } -void Car::showNetwork(bool a) - { - SData->viewNetwork=a; - } -bool Car::showNetworkState() - { - return SData->viewNetwork; - } diff --git a/InterfaceCpp/car.h~ b/InterfaceCpp/car.h~ deleted file mode 100644 index 6480ac1..0000000 --- a/InterfaceCpp/car.h~ +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __CAR_H -#define __CAR_H - -#define PI 3.141592 -#define ANGLESTEP 5 -#define TRAINEESIZE 8192 -#include "shmdata.h" - -class Car - { - private : - SDL_Surface *Surface_car[360]; - SDL_Rect rect; - bool carimage; - bool showbar; - bool camera[CAMVECT]; - struct shmdata *SData; - int shmid; - int angstep; - - int trainee[TRAINEESIZE][2]; - int traineepos; - int traineesize; - public : - Car(); - void updateCar(SDL_Surface* screen); - void loadImage(char *imagefile); - void initShm(); - - int incTraineeSize(int); - void incAngle(); - void decAngle(); - void incSpeed(); - void decSpeed(); - int incAngleStep(int); - bool APToggle(); - bool APState() const; - bool neurToggle(); - bool neurState() const; - int getSpeed() const; - int getAngle() const; - bool showBar(int i); - bool* getVect(); - bool* getView(); - void reset(); - void turn180(); - void showCamera(SDL_Surface* screen); - void showTrainee(SDL_Surface* screen); - void loadState(); - void saveState(); - void harakiri(); - void setDelay(int del); - bool showNetwork(bool a); - bool showNetworkState(); - }; - -#endif diff --git a/InterfaceCpp/fenetre.cpp~ b/InterfaceCpp/fenetre.cpp~ deleted file mode 100644 index 86a99a3..0000000 --- a/InterfaceCpp/fenetre.cpp~ +++ /dev/null @@ -1,376 +0,0 @@ -#include -#include -#include -#include -#include "sdlcommon.h" -#include "fenetre.h" -#include "shmdata.h" - -using namespace std; - -Fenetre::Fenetre () - { - obstacle=0; - SHOWcamera=1; - SHOWpilot=1; - fps=0; - font=SFont_InitFont(IMG_Load(FONT_PATH)); - if( SDL_Init(SDL_INIT_VIDEO) < 0 ) - { - fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError()); - return ; - } - atexit(SDL_Quit); - screen = SDL_SetVideoMode(800,600, 32, SDL_HWSURFACE); - /* SDL_HWSURFACE / SDL_SWSURFACE */ - /*|SDL_ANYFORMAT*/ - if( screen==NULL ) - { - fprintf(stderr, "Could not create surface: %s\n", SDL_GetError()); - return ; - } - return ; - Voiture.loadImage("Cars/voiture4.bmp"); - circuit=1; - } - -Fenetre::Fenetre (int largeur = 800, int hauteur = 600, int nb_couleurs = 16, char *titre = "Fenetre SDL", char *background=NULL) - { - obstacle=0; - SHOWcamera=1; - SHOWpilot=1; - fps=0; - font=SFont_InitFont(IMG_Load(FONT_PATH)); - if (SDL_Init (SDL_INIT_VIDEO) < 0) - { - cerr << "Erreur dans l'initialisation de la librairie" << endl; - } - - screen = SDL_SetVideoMode (largeur, hauteur, nb_couleurs, SDL_HWSURFACE | SDL_DOUBLEBUF); - //SDL_CreateRGBSurface(SDL_HWSURFACE, largeur,hauteur,32,0,0,0,0); - if (screen == NULL) - { - cerr << "Erreur dans l'initialisation des modes vidéos:" << - SDL_GetError (); - SDL_Quit (); - } - SDL_WM_SetCaption (titre, NULL); - fond = SDL_LoadBMP (background); - SDL_BlitSurface (fond, NULL, screen, NULL); - SDL_Flip (screen); - HardBG=SDL_CreateRGBSurface(SDL_HWSURFACE, largeur, hauteur, 32, 0,0,0,0); - SDL_BlitSurface( fond, NULL, HardBG, NULL); - Voiture.loadImage("Cars/voiture4.bmp"); - circuit=1; - } - -void Fenetre::loadBG(char *background) - { - fond = SDL_LoadBMP (background); - SDL_BlitSurface (fond, NULL, /*screen*/HardBG, NULL); - SDL_BlitSurface( fond, NULL, HardBG, NULL); - SDL_Flip (screen); - } - -Fenetre::~Fenetre () - { - /* - if(fond) SDL_FreeSurface (fond); - if(screen) SDL_FreeSurface (screen); - */ - SDL_Quit (); - - } -void Fenetre::showView(int x,int y) - { - bool* v=Voiture.getView(); - SDL_Rect r; - r.x=x; r.y=y-1; r.h=1; r.w=4*CAMVECT; - SDL_FillRect(screen,&r, SDL_MapRGB(screen->format, 255,0,0)); - r.x=x; r.y=y+4; r.h=1; r.w=4*CAMVECT; - SDL_FillRect(screen,&r, SDL_MapRGB(screen->format, 255,0,0)); - for(int i=0;iformat, 0,0,0)); - } - } - } - -void Fenetre::showObstacle() - { - SDL_Rect r; - r.x=400; - r.y=20; - r.w=40; - r.h=screen->h-40; - SDL_FillRect(screen,&r, SDL_MapRGB(screen->format, 255,0,0)); - } - -void Fenetre::showPilot(int x,int y) - { - if(Voiture.getVect()[0]) - for(int i=0;i<16;i++) - { - for(int j=y-i;jaction=SAVE_STATE; - break; - case SDLK_x: - Voiture.loadState(); - //SData->action=RELOAD_STATE; - break; - case SDLK_F1: - printf("Chargement Circuit 1\n"); - circuit=1; - loadBG("Back/bg1.bmp"); - break; - case SDLK_F2: - printf("Chargement Circuit 2\n"); - circuit=2; - loadBG("Back/bg2.bmp"); - break; - case SDLK_F3: - printf("Chargement Circuit 3\n"); - circuit=3; - loadBG("Back/bg3.bmp"); - break; - case SDLK_F4: - printf("Chargement Circuit 4\n"); - circuit=4; - loadBG("Back/bg4.bmp"); - break; - case SDLK_F5: - printf("Chargement Circuit 5\n"); - circuit=5; - loadBG("Back/bg5.bmp"); - break; - case SDLK_F6: - printf("Chargement Circuit 6\n"); - circuit=6; - loadBG("Back/bg6.bmp"); - break; - case SDLK_F7: - Voiture.incTraineeSize(-256); - break; - case SDLK_F8: - Voiture.incTraineeSize(256); - break; - case SDLK_F9: - printf("Chargement Voiture 1\n"); - Voiture.loadImage("Cars/voiture1.bmp"); - break; - case SDLK_F10: - printf("Chargement Voiture 2\n"); - Voiture.loadImage("Cars/voiture2.bmp"); - break; - case SDLK_F11: - printf("Chargement Voiture 3\n"); - Voiture.loadImage("Cars/voiture3.bmp"); - break; - case SDLK_F12: - printf("Chargement Voiture 4\n"); - Voiture.loadImage("Cars/voiture4.bmp"); - break; - case SDLK_PAGEUP: - Voiture.incAngleStep(1); - break; - case SDLK_PAGEDOWN: - Voiture.incAngleStep(-1); - break; - - case SDLK_HOME: - waitdel+=5; - break; - case SDLK_END: - waitdel-=5; - if(waitdel<0) waitdel=0; - break; - - default : - break; - } - break; - } - break; - } - } - } diff --git a/InterfaceCpp/fenetre.h~ b/InterfaceCpp/fenetre.h~ deleted file mode 100644 index 57fe516..0000000 --- a/InterfaceCpp/fenetre.h~ +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __FENETRE_H -#define __FENETRE_H - -#include "car.h" -#include "SFont.h" -#define FONT_PATH "font.png" - -class Fenetre - { - private: - SDL_Surface* screen; - SDL_Surface* fond; - SDL_Surface* HardBG; - SFont_Font* font; - car Voiture; - int frame,sec,fps,circuit; - bool SHOWpilot,SHOWcamera,obstacle; - - public: - Fenetre(); - Fenetre (int , int , int , char *, char *); - ~Fenetre(); - void loadBG(char *); - void redraw(); - void handle(); - void putPixel(int , int , char, char, char); - void showView(int ,int); - void showPilot(int,int); - void showObstacle(); - void drawText(); - - }; - -#endif diff --git a/InterfaceCpp/sdlcommon.h~ b/InterfaceCpp/sdlcommon.h~ deleted file mode 100644 index 58ad715..0000000 --- a/InterfaceCpp/sdlcommon.h~ +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __SDLCOMMON_H -#define __SDLCOMMON_H - -#ifndef PI -#define PI 3.141592 -#endif - -#ifndef NULLCOL -#define NULLCOL 0x00FF00FF - -#define NULLCOLA 0xFF -#define NULLCOLR 0xFF -#define NULLCOLG 0x00 -#define NULLCOLB 0xFF -#endif - - - -void setpixel(SDL_Surface*, int, int, Uint8, Uint8, Uint8); -int getpixel(SDL_Surface*, int, int); -void DrawLine(SDL_Surface*, int , int , int , int , char , char, char); -void rotatesurface(SDL_Surface*, SDL_Surface*, int); -void interpole(SDL_Surface* , SDL_Surface* , Uint32 ); -bool inCarArea(SDL_Surface* , int , int ); - -#endif diff --git a/InterfaceCpp/shmdata.h~ b/InterfaceCpp/shmdata.h~ deleted file mode 100644 index a83703b..0000000 --- a/InterfaceCpp/shmdata.h~ +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __SHMDATA_H -#define __SHMDATA_H -#define SHMKEY 5678 - -#define CAMERASIZE 128 -#define CAMERASTEP 2 -#define CAMERADISTANCE 50 -#define CAMVECT (CAMERASIZE/CAMERASTEP) - -#define NOMBRE_NEURONES_INTERMEDIAIRES 8 -#define TAILLERESULTAT 3 - -#define SAVE_STATE 1 -#define RELOAD_STATE 2 -#define STATE_FILE "State.network" - -struct shmdata - { - bool V[CAMVECT]; /* vecteur camera */ - bool Res[3]; /* 0 gauche 1 droite 2 avancer 3 stop*/ - int read; /* 1 = info a ete traitée */ - int angle; /* angle de la voiture 0->359 */ - int speed; /* vitesse */ - int APon; /* pilote automatique (mode apprentissage) (0/1) */ - int Neuron; /* activer le reseau de neurone (0/1) */ - double pos_x; /* position x de la voiture */ - double pos_y; /* position y de la voiture */ - int action; /* action a executer (genre sauvegarde) */ - int delay; /* delai entre les frames */ - }; - -#endif - diff --git a/Rapport/class1.dia~ b/Rapport/class1.dia~ deleted file mode 100644 index a9c83e0..0000000 --- a/Rapport/class1.dia~ +++ /dev/null @@ -1,1861 +0,0 @@ - - - - - - - - - - - - - #A4# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Neurone# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Couche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Reseau# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Synapse# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #SynapseMatrix# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Utils# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #InputCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #HiddenCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #OutputCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Game# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Fenetre# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Car# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - diff --git a/Rapport/class1UML0.dia~ b/Rapport/class1UML0.dia~ deleted file mode 100644 index fee7f0c..0000000 --- a/Rapport/class1UML0.dia~ +++ /dev/null @@ -1,3264 +0,0 @@ - - - - - - - - - - - - - #A4# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Neurone# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Couche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Reseau# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #SData# - - - #struct shmdata*# - - - ## - - - ## - - - - - - - - - - - - - - #shmid# - - - #int# - - - ## - - - ## - - - - - - - - - - - - - - #util# - - - #Utils# - - - ## - - - ## - - - - - - - - - - - - - - #Icouche# - - - #InputCouche# - - - ## - - - ## - - - - - - - - - - - - - - #Hcouche# - - - #HiddenCouche# - - - ## - - - ## - - - - - - - - - - - - - - #Ocouche# - - - #OutputCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - #Reseau# - - - ## - - - ## - - - - - - ## - - - - - - - - - - - - - - - - - - #~Reseau# - - - ## - - - ## - - - - - - ## - - - - - - - - - - - - - - - - - - #Reseau# - - - ## - - - ## - - - - - - ## - - - - - - - - - - - - - - - - - #In# - - - #int# - - - ## - - - ## - - - - - - - - #Hid# - - - #int# - - - ## - - - ## - - - - - - - - #Out# - - - #int# - - - ## - - - ## - - - - - - - - - - #rebuild# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - #In# - - - #int# - - - ## - - - ## - - - - - - - - #Hid# - - - #int# - - - ## - - - ## - - - - - - - - #Out# - - - #int# - - - ## - - - ## - - - - - - - - ## - - - ## - - - ## - - - ## - - - - - - - - - - #forward# - - - ## - - - #std::vector<double># - - - - - - ## - - - - - - - - - - - - - - - - - #input# - - - #bool*# - - - ## - - - ## - - - - - - - - - - #backward# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - #input# - - - #bool*# - - - ## - - - ## - - - - - - - - #target# - - - #bool*# - - - ## - - - ## - - - - - - - - ## - - - ## - - - ## - - - ## - - - - - - - - - - #learnOne# - - - ## - - - #double# - - - - - - ## - - - - - - - - - - - - - - - - - #input# - - - #bool*# - - - ## - - - ## - - - - - - - - #target# - - - #bool*# - - - ## - - - ## - - - - - - - - ## - - - ## - - - ## - - - ## - - - - - - - - - - #learnAll# - - - ## - - - #double# - - - - - - ## - - - - - - - - - - - - - - - - - #inputs# - - - #std::vector<bool*># - - - ## - - - ## - - - - - - - - #targets# - - - #std::vector<bool*># - - - ## - - - ## - - - - - - - - - - #saveState# - - - ## - - - #voild# - - - - - - ## - - - - - - - - - - - - - - - - - #filename# - - - #const char*# - - - ## - - - ## - - - - - - - - - - #loadState# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - #filename# - - - #const char*# - - - ## - - - ## - - - - - - - - - - #operator=# - - - ## - - - #Reseau&# - - - - - - ## - - - - - - - - - - - - - - - - - #c# - - - #Reseau&# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Synapse# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #SynapseMatrix# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Utils# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Utils# - - - ## - - - ## - - - - - - ## - - - - - - - - - - - - - - - - - - #sigmoid# - - - ## - - - #double# - - - - - - ## - - - - - - - - - - - - - - - - - #val# - - - #double# - - - ## - - - ## - - - - - - - - - - #dsigmoid# - - - ## - - - #double# - - - - - - ## - - - - - - - - - - - - - - - - - #val# - - - #double# - - - ## - - - ## - - - - - - - - - - #accept# - - - ## - - - #bool# - - - - - - ## - - - - - - - - - - - - - - - - - #val# - - - #double# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #InputCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #HiddenCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #OutputCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Game# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #shmid# - - - #int# - - - ## - - - ## - - - - - - - - - - - - - - #neurError# - - - #bool# - - - ## - - - ## - - - - - - - - - - - - - - #showOutput# - - - #bool# - - - ## - - - ## - - - - - - - - - - - - - - #data# - - - #struct shmdata*# - - - ## - - - ## - - - - - - - - - - - - - - #R# - - - #Reseau# - - - ## - - - ## - - - - - - - - - - - - - - - - #Game# - - - ## - - - ## - - - - - - ## - - - - - - - - - - - - - - - - - - #preLearn# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - - #preTest# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - - #shmCreate# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - - #pilot# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - #data# - - - #struct shmdata*# - - - ## - - - ## - - - - - - - - - - #leanThis# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - - #neuronThis# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - - #Run# - - - ## - - - #void# - - - - - - ## - - - - - - - - - - - - - - - - - - #toggleShow# - - - ## - - - #voild# - - - - - - ## - - - - - - - - - - - - - - - - - #t# - - - #bool# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Fenetre# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Car# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - diff --git a/Rapport/class2.dia~ b/Rapport/class2.dia~ deleted file mode 100644 index 9fee036..0000000 --- a/Rapport/class2.dia~ +++ /dev/null @@ -1,1860 +0,0 @@ - - - - - - - - - - - - - #A4# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Neurone# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Couche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Reseau# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Synapse# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #SynapseMatrix# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Utils# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #InputCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #HiddenCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #OutputCouche# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Game# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Fenetre# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Car# - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## - - - - - - - - ## - - - ## - - - - - - - - - - - ## - - - ## - - - - - - - - - - - - - - - - diff --git a/backprop/global.h~ b/backprop/global.h~ deleted file mode 100644 index 563dbce..0000000 --- a/backprop/global.h~ +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _GLOBAL_H -#define _GLOBAL_H -#define SYNAPSE_WEIGHT_MAX 2.0 -#define SYNAPSE_WEIGHT_MIN -2.0 -#define LEARNING_RATE 0.01 -#define MOMENTUM 0.1 -#define ACCEPT 0.65 /* Was 0.95 */ -#define LEARNACCEPT 0.15 /* Was 0.05 */ - - -#endif diff --git a/backprop/reseau.cpp~ b/backprop/reseau.cpp~ deleted file mode 100644 index 34b2e4f..0000000 --- a/backprop/reseau.cpp~ +++ /dev/null @@ -1,184 +0,0 @@ -#include "reseau.h" - -Reseau::Reseau() - { - } - -Reseau::Reseau(int In, int Hid, int Out) - { - In++; // pour le noeud de bias - Ocouche=OutputCouche(Out); - Hcouche=HiddenCouche(Hid,&Ocouche); - Icouche=InputCouche(In,&Hcouche); - Ocouche.setPrevCouche(&Hcouche); - //Icouche.printSynapseMatrix(); - //Hcouche.printSynapseMatrix(); - } -void Reseau::rebuild(int In, int Hid, int Out) // METHODE BOURRAIN SPOTTED - { - In++; - Ocouche=OutputCouche(Out); - Hcouche=HiddenCouche(Hid,&Ocouche); - Icouche=InputCouche(In,&Hcouche); - Ocouche.setPrevCouche(&Hcouche); - Icouche.printSynapseMatrix(); - Hcouche.printSynapseMatrix(); - } - -Reseau::~Reseau(){ -} - -void Reseau::saveState(const char* filename) throw(std::string){ - unsigned sizeinput = Icouche.getNumber(); - unsigned sizehidden = Hcouche.getNumber(); - unsigned sizeoutput = Ocouche.getNumber(); - std::ofstream outFile(filename); - if(outFile.fail()){ - throw(std::string("Couldn't open output file")); - } - outFile << sizeinput << " " << sizehidden << " " << sizeoutput << endl; - for( unsigned int i=0 ; i < sizeinput ; ++i ) - for( unsigned int j=0 ; j < sizehidden ; ++j ) - outFile << Icouche.getSynapse(i,j).getWeight() << " " << endl; - for( unsigned int i=0 ; i < sizehidden ; ++i ) - for( unsigned int j=0 ; j < sizeoutput ; ++j ) - outFile << Hcouche.getSynapse(i,j).getWeight() << " " << endl; - outFile.close(); -} - -void Reseau::loadState(const char* filename) throw(std::string){ - std::ifstream inpFile(filename); - unsigned int sizeinput,sizehidden,sizeoutput; - if(inpFile.fail()){ - cout << "Can't open input file" << endl; - throw(std::string("Couldn't open output file")); - } - if(!(inpFile >> sizeinput >> sizehidden >> sizeoutput)) - cout<<"Super error!!!" << endl; - if(sizeinput!=Icouche.getNumber() || sizehidden!=Hcouche.getNumber() || sizeoutput != Ocouche.getNumber()){ - throw(std::string("Wrong size of Couche in file")); - } - double tmpDouble; - //for( unsigned int i=0 ; i < sizeinput ; ++i ) - for( unsigned int i=0 ; i < sizeinput ; ++i ){ - for( unsigned int j=0 ; j < sizehidden ; ++j ){ - if(!(inpFile >> tmpDouble)){ - cout << "Input ERROR" << endl; - } - Icouche.getSynapse(i,j).setWeight(tmpDouble); - } - } - - for( unsigned int i=0 ; i < sizehidden ; ++i ){ - for( unsigned int j=0 ; j < sizeoutput ; ++j ){ - if(!(inpFile >> tmpDouble)){ - cout << "Input ERROR" << endl; - } - Hcouche.getSynapse(i,j).setWeight(tmpDouble); - } - } - //cout << "==========After=========" << endl; - Icouche.printSynapseMatrix(); - inpFile.close(); - //cout << sizeinput << " " << sizehidden << " " << sizeoutput << endl; -} - -std::vector Reseau::forward(bool input[]) - { - std::vector tmp; - /* on active les couches */ - for(unsigned i=0;i<(Icouche.getNumber()-1);i++) /* faut passer n-1 brol dans le vecteur d'activation car il y a le neurone de bias ... */ - { - tmp.push_back(input[i]); - } - Icouche.activate(tmp); - Hcouche.activate(Icouche); - Ocouche.activate(); - /* on place le resultat dans la shm */ - //for(unsigned i=0;i resultat; - for(unsigned i=0;i hidDelta; - std::vector outDelta; - double error; - hidDelta.clear(); - outDelta.clear(); - /* Calcul des delta pour la couche OUPUT */ - for(unsigned i=0;i