init commit
This commit is contained in:
23
server/.#Makefile.1.8
Normal file
23
server/.#Makefile.1.8
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
CFLAGS= -Wall -g -ansi -I/usr/include/SDL
|
||||
SDLLDFLAGS= -L/usr/lib -lSDL -lpthread -lSDL_image
|
||||
DEFINE= -D_XOPEN_SOURCE -D_GNU_SOURCE
|
||||
GCC= g++
|
||||
|
||||
all : autopilot
|
||||
autopilot : Autopilot.o
|
||||
# $(MAKE) -C ../backprop
|
||||
$(GCC) $(CFLAGS) $(SDLLDFLAGS) -o AutoPilot AutoPilot.o reseauSDL.o game.o ../backprop/couche.o ../backprop/hiddenCouche.o ../backprop/inputCouche.o ../backprop/neurone.o ../backprop/outputCouche.o ../backprop/reseau.o ../backprop/synapseMatrix.o ../backprop/synapse.o ../backprop/Utils.o ../InterfaceCpp/sdlcommon.o
|
||||
|
||||
Autopilot.o : AutoPilot.cpp
|
||||
$(GCC) $(CFLAGS) $(DEFINE) -c AutoPilot.cpp
|
||||
$(GCC) $(CFLAGS) $(DEFINE) -c game.cpp
|
||||
$(GCC) $(CFLAGS) $(DEFINE) -c reseauSDL.cpp
|
||||
|
||||
clean :
|
||||
rm -rf *.o
|
||||
# $(MAKE) -C ../backprop clean
|
||||
|
||||
mrproper :
|
||||
rm -rf *.o
|
||||
rm -rf AutoPilot
|
||||
210
server/.#game.cpp.1.13
Normal file
210
server/.#game.cpp.1.13
Normal file
@@ -0,0 +1,210 @@
|
||||
#include "game.h"
|
||||
#include "carlearn.h"
|
||||
|
||||
Game::Game()
|
||||
{
|
||||
shmCreate();
|
||||
data->read=0;
|
||||
data->Res[2]=1;
|
||||
R.rebuild(CAMVECT,NOMBRE_NEURONES_INTERMEDIAIRES,TAILLERESULTAT);
|
||||
neurError=1;
|
||||
data->Neuron=0;
|
||||
data->action=0;
|
||||
data->APon=1;
|
||||
data->viewNetwork=0;
|
||||
showOutput=1;
|
||||
#ifdef __SHOW_NETWORK
|
||||
rSDL.setReseau(&R);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Game::shmCreate()
|
||||
{
|
||||
if ((shmid = shmget(SHMKEY, sizeof(struct shmdata), IPC_CREAT | 0666)) < 0)
|
||||
{
|
||||
perror("shmget");
|
||||
exit(1);
|
||||
}
|
||||
if ((data = (struct shmdata *) shmat(shmid, NULL, 0)) == (struct shmdata *) -1)
|
||||
{
|
||||
perror("shmat");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::pilot(struct shmdata *data)
|
||||
{
|
||||
int i,z1=0,z2=0,center,np=0;
|
||||
for(i=0;i<VSIZE;i++)
|
||||
{
|
||||
np+=(data->V[i]+1)%2;
|
||||
if(data->V[i]==1 && z1==0)
|
||||
{
|
||||
z1=i;
|
||||
while(data->V[i]==1) i++;
|
||||
z1+=i;
|
||||
z1/=2;
|
||||
}
|
||||
else if(data->V[i]==1)
|
||||
{
|
||||
z2=i;
|
||||
while(data->V[i]==1) i++;
|
||||
z2+=i;
|
||||
z2/=2;
|
||||
}
|
||||
}
|
||||
/* printf("zones : %d , %d \n",z1,z2); */
|
||||
if(z1&&z2) center=(z1+z2)/2;
|
||||
else if(z1) center=z1;
|
||||
else if(z2) center=z2;
|
||||
else center=VSIZE/2;
|
||||
if(np>(VSIZE/2))
|
||||
{
|
||||
data->Res[2]=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->Res[2]=0;
|
||||
}
|
||||
if(center < (VSIZE/2)-2 )
|
||||
data->Res[0]=1;
|
||||
else if(center > (VSIZE/2)+2 )
|
||||
data->Res[1]=1;
|
||||
}
|
||||
|
||||
void Game::learnThis()
|
||||
{
|
||||
if(showOutput)
|
||||
{
|
||||
cout << " LEARN : " ;
|
||||
for(int i=0;i<TAILLERESULTAT;i++)
|
||||
cout << " [" << data->Res[i] << "]";
|
||||
}
|
||||
neurError+=R.learnOne(data->V,data->Res);
|
||||
neurError/=2;
|
||||
}
|
||||
|
||||
void Game::neuronThis()
|
||||
{
|
||||
Utils u;
|
||||
std::vector<double> V;
|
||||
V=R.forward(data->V);
|
||||
if(showOutput) cout << " neuron reply : ";
|
||||
for(unsigned i=0;i<V.size();i++)
|
||||
{
|
||||
data->Res[i]=u.accept(V[i]);
|
||||
if(showOutput) cout << " " << data->Res[i];
|
||||
}
|
||||
if(showOutput) cout << " bool :";
|
||||
for(unsigned i=0;i<V.size();i++)
|
||||
{
|
||||
if(showOutput) printf(" %7.4f",(float)V[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::Run()
|
||||
{
|
||||
unsigned int cpt;
|
||||
for(cpt=0;data->read!=666;cpt++)
|
||||
{
|
||||
#ifdef __SHOW_NETWORK
|
||||
rSDL.setState(data->viewNetwork);
|
||||
if(!(cpt%16)) rSDL.refresh();
|
||||
#endif
|
||||
while(data->read==0) usleep(data->delay/2); // on attends que la voiture ait bougé
|
||||
if(data->read==666) break;
|
||||
|
||||
if(showOutput)
|
||||
{
|
||||
cout << "V = ";
|
||||
for(i=0;i<VSIZE;i++)
|
||||
{
|
||||
if(data->V[i]) cout << " ";
|
||||
else cout << "#";
|
||||
}
|
||||
}
|
||||
|
||||
if(data->action==SAVE_STATE)
|
||||
{
|
||||
cout << "Enregistrement de l'etat du reseau dans le fichier : " << STATE_FILE << endl;
|
||||
data->action=0;
|
||||
R.saveState(STATE_FILE);
|
||||
}
|
||||
else if(data->action==RELOAD_STATE)
|
||||
{
|
||||
cout << "Restauration de l'etat du reseau dans le fichier : " << STATE_FILE << endl;
|
||||
data->action=0;
|
||||
R.loadState(STATE_FILE);
|
||||
}
|
||||
if(data->APon==1)
|
||||
{
|
||||
pilot(data); // mode pilot automatique
|
||||
if(showOutput)
|
||||
{
|
||||
cout << " AP= ";
|
||||
for(i=0;i<TAILLERESULTAT;i++) printf(" %d",data->Res[i]);
|
||||
}
|
||||
}
|
||||
if(data->Neuron==1)
|
||||
{
|
||||
if(data->APon) // mode apprentissage (neurone + pilote)
|
||||
learnThis();
|
||||
else // neurone seul
|
||||
{
|
||||
neuronThis();
|
||||
}
|
||||
}
|
||||
if(showOutput) printf("\n");
|
||||
data->read=0;
|
||||
}
|
||||
cout << " EXIT AutoPilot ... " << endl;
|
||||
}
|
||||
void Game::preLearn()
|
||||
{
|
||||
// double learnAll(std::vector<bool *> inputs, std::vector<bool *> targets);
|
||||
std::vector<bool *> in;
|
||||
std::vector<bool *> r;
|
||||
int cpt=0;
|
||||
double erreur=0;
|
||||
|
||||
for(int i=0;i<PREtests;i++)
|
||||
{
|
||||
in.push_back(VoitureLearnI[i]);
|
||||
r.push_back(VoitureLearnR[i]);
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
++cpt;
|
||||
erreur += R.learnAll(in,r);
|
||||
if(erreur < LEARNACCEPT)
|
||||
break;
|
||||
if(cpt%100 == 0)
|
||||
{
|
||||
erreur/=100;
|
||||
cout << " : step " << cpt << " error:" << erreur << endl;
|
||||
erreur=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
void Game::preTest()
|
||||
{
|
||||
Utils u;
|
||||
std::vector<double> V;
|
||||
for(int i=0;i<PREtests;i++)
|
||||
{
|
||||
V=R.forward(VoitureLearnI[i]);
|
||||
cout << "pour : ";
|
||||
for(int j=0;j<64;j++) cout << VoitureLearnI[i][j] ;
|
||||
for(unsigned i=0;i<V.size();i++)
|
||||
cout << " [" << u.accept(V[i]) << "]";
|
||||
cout << " bool " ;
|
||||
for(unsigned i=0;i<V.size();i++)
|
||||
cout << " [" << V[i] << "] " ;
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
void Game::toggleShow(bool t)
|
||||
{
|
||||
showOutput=t;
|
||||
}
|
||||
43
server/.#game.h.1.5
Normal file
43
server/.#game.h.1.5
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef __GAME_H
|
||||
#define __GAME_H
|
||||
|
||||
#define VSIZE 64
|
||||
#include "../InterfaceCpp/shmdata.h"
|
||||
|
||||
#include "../backprop/neurone.h"
|
||||
#include "../backprop/couche.h"
|
||||
#include "../backprop/inputCouche.h"
|
||||
#include "../backprop/synapse.h"
|
||||
#include "../backprop/synapseMatrix.h"
|
||||
#include "../backprop/reseau.h"
|
||||
#include "../backprop/Utils.h"
|
||||
|
||||
#define __SHOW_NETWORK
|
||||
|
||||
#ifdef __SHOW_NETWORK
|
||||
#include "reseauSDL.h"
|
||||
#endif
|
||||
|
||||
class Game{
|
||||
private :
|
||||
int shmid,i;
|
||||
bool neurError,showOutput;
|
||||
struct shmdata *data;
|
||||
Reseau R;
|
||||
#ifdef __SHOW_NETWORK
|
||||
ReseauSDL rSDL;
|
||||
#endif
|
||||
public :
|
||||
Game();
|
||||
void preLearn();
|
||||
void preTest();
|
||||
|
||||
void shmCreate();
|
||||
void pilot(struct shmdata *data);
|
||||
void learnThis();
|
||||
void neuronThis();
|
||||
void Run();
|
||||
void toggleShow(bool t);
|
||||
};
|
||||
|
||||
#endif
|
||||
58
server/AutoPilot.cpp
Normal file
58
server/AutoPilot.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include "game.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void showHelp()
|
||||
{
|
||||
cout << " -n pas de Pré apprentissage" << endl;
|
||||
cout << " -s ne pas afficher d'output dans la console" << endl;
|
||||
cout << " -h afficher cette aide " << endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Game G;
|
||||
int i,prelearn=1;
|
||||
bool showoutput=1;
|
||||
for (i=1;i<argc;i++)
|
||||
{
|
||||
if(!strcmp("-n",argv[i])) prelearn=0;
|
||||
if(!strcmp("-s",argv[i])) showoutput=0;
|
||||
if(!strcmp("-h",argv[i]))
|
||||
{
|
||||
showHelp();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
G.toggleShow(showoutput);
|
||||
if(prelearn)
|
||||
{
|
||||
cout << "Learn ....\n";
|
||||
G.preLearn();
|
||||
G.preTest();
|
||||
cout << "Learn OK ...\n";
|
||||
cout << "press a key !\n";
|
||||
cin >> i;
|
||||
}
|
||||
|
||||
cout << "Start interface\n";
|
||||
|
||||
if(fork()==0)
|
||||
{
|
||||
chdir("InterfaceCpp");
|
||||
execv("iface",argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
G.Run();
|
||||
exit(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
BIN
server/AutoPilot.o
Normal file
BIN
server/AutoPilot.o
Normal file
Binary file not shown.
8
server/CVS/Entries
Normal file
8
server/CVS/Entries
Normal file
@@ -0,0 +1,8 @@
|
||||
/AutoPilot.cpp/1.9/Wed Apr 13 15:04:03 2005//
|
||||
/carlearn.h/1.6/Wed Apr 13 15:04:03 2005//
|
||||
/Makefile/1.9/Thu Apr 14 17:38:18 2005//
|
||||
/game.h/1.6/Thu Apr 14 17:38:18 2005//
|
||||
/game.cpp/1.15/Thu Apr 14 17:38:44 2005//
|
||||
/reseauSDL.cpp/1.2/Thu Apr 14 17:39:11 2005//
|
||||
/reseauSDL.h/1.2/Thu Apr 14 17:38:22 2005//
|
||||
D
|
||||
1
server/CVS/Repository
Normal file
1
server/CVS/Repository
Normal file
@@ -0,0 +1 @@
|
||||
ia2005/server
|
||||
1
server/CVS/Root
Normal file
1
server/CVS/Root
Normal file
@@ -0,0 +1 @@
|
||||
:pserver:feeling@jfroche.be:/opt/cvsroot
|
||||
25
server/Makefile
Normal file
25
server/Makefile
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
CFLAGS= -Wall -g -ansi -I/usr/include/SDL -std=c++14
|
||||
SDLLDFLAGS= -L/usr/lib -lSDL -lpthread -lSDL_image
|
||||
DEFINE= -D_XOPEN_SOURCE -D_GNU_SOURCE
|
||||
GCC= g++
|
||||
|
||||
all : autopilot
|
||||
autopilot : Autopilot.o
|
||||
# $(MAKE) -C ../backprop
|
||||
$(GCC) -o AutoPilot AutoPilot.o reseauSDL.o game.o ../backprop/couche.o ../backprop/hiddenCouche.o ../backprop/inputCouche.o ../backprop/neurone.o ../backprop/outputCouche.o ../backprop/reseau.o ../backprop/synapseMatrix.o ../backprop/synapse.o ../backprop/Utils.o ../InterfaceCpp/sdlcommon.o -L/usr/lib -lSDL -lpthread -lSDL_image -Wno-deprecated -I/usr/include/SDL -std=c++14
|
||||
|
||||
Autopilot.o : AutoPilot.cpp
|
||||
$(GCC) -c AutoPilot.cpp -L/usr/lib -I/usr/include/SDL -Wno-deprecated -std=c++14
|
||||
$(GCC) -c game.cpp -L/usr/lib -I/usr/include/SDL -Wno-deprecated -std=c++14
|
||||
$(GCC) -c reseauSDL.cpp -L/usr/lib -I/usr/include/SDL -Wno-deprecated -std=c++14
|
||||
|
||||
clean :
|
||||
rm -rf *.o
|
||||
# $(MAKE) -C ../backprop clean
|
||||
|
||||
mrproper :
|
||||
rm -rf *.o
|
||||
rm -rf AutoPilot
|
||||
|
||||
|
||||
205
server/carlearn.h
Normal file
205
server/carlearn.h
Normal file
@@ -0,0 +1,205 @@
|
||||
#ifndef __CARLEARN_H
|
||||
#define __CARLEARN_H
|
||||
|
||||
int PREtests=38;
|
||||
|
||||
static bool VoitureLearnI[86][64]=
|
||||
{
|
||||
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
|
||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
||||
};
|
||||
*/
|
||||
static bool VoitureLearnR[86][3]=
|
||||
{
|
||||
{0,0,0},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{1,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
{0,1,1},
|
||||
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1},
|
||||
{0,0,1}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
210
server/game.cpp
Normal file
210
server/game.cpp
Normal file
@@ -0,0 +1,210 @@
|
||||
#include "game.h"
|
||||
#include "carlearn.h"
|
||||
|
||||
Game::Game()
|
||||
{
|
||||
shmCreate();
|
||||
data->read=0;
|
||||
data->Res[2]=1;
|
||||
R.rebuild(CAMVECT,NOMBRE_NEURONES_INTERMEDIAIRES,TAILLERESULTAT);
|
||||
neurError=1;
|
||||
data->Neuron=0;
|
||||
data->action=0;
|
||||
data->APon=1;
|
||||
data->viewNetwork=0;
|
||||
showOutput=1;
|
||||
#ifdef __SHOW_NETWORK
|
||||
rSDL.setReseau(&R);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Game::shmCreate()
|
||||
{
|
||||
if ((shmid = shmget(SHMKEY, sizeof(struct shmdata), IPC_CREAT | 0666)) < 0)
|
||||
{
|
||||
perror("shmget");
|
||||
exit(1);
|
||||
}
|
||||
if ((data = (struct shmdata *) shmat(shmid, NULL, 0)) == (struct shmdata *) -1)
|
||||
{
|
||||
perror("shmat");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::pilot(struct shmdata *data)
|
||||
{
|
||||
int i,z1=0,z2=0,center,np=0;
|
||||
for(i=0;i<VSIZE;i++)
|
||||
{
|
||||
np+=(data->V[i]+1)%2;
|
||||
if(data->V[i]==1 && z1==0)
|
||||
{
|
||||
z1=i;
|
||||
while(data->V[i]==1) i++;
|
||||
z1+=i;
|
||||
z1/=2;
|
||||
}
|
||||
else if(data->V[i]==1)
|
||||
{
|
||||
z2=i;
|
||||
while(data->V[i]==1) i++;
|
||||
z2+=i;
|
||||
z2/=2;
|
||||
}
|
||||
}
|
||||
/* printf("zones : %d , %d \n",z1,z2); */
|
||||
if(z1&&z2) center=(z1+z2)/2;
|
||||
else if(z1) center=z1;
|
||||
else if(z2) center=z2;
|
||||
else center=VSIZE/2;
|
||||
if(np>(VSIZE/2))
|
||||
{
|
||||
data->Res[2]=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->Res[2]=0;
|
||||
}
|
||||
if(center < (VSIZE/2)-2 )
|
||||
data->Res[0]=1;
|
||||
else if(center > (VSIZE/2)+2 )
|
||||
data->Res[1]=1;
|
||||
}
|
||||
|
||||
void Game::learnThis()
|
||||
{
|
||||
if(showOutput)
|
||||
{
|
||||
cout << " LEARN : " ;
|
||||
for(int i=0;i<TAILLERESULTAT;i++)
|
||||
cout << " [" << data->Res[i] << "]";
|
||||
}
|
||||
neurError+=R.learnOne(data->V,data->Res);
|
||||
neurError/=2;
|
||||
}
|
||||
|
||||
void Game::neuronThis()
|
||||
{
|
||||
Utils u;
|
||||
std::vector<double> V;
|
||||
V=R.forward(data->V);
|
||||
if(showOutput) cout << " neuron reply : ";
|
||||
for(unsigned i=0;i<V.size();i++)
|
||||
{
|
||||
data->Res[i]=u.accept(V[i]);
|
||||
if(showOutput) cout << " " << data->Res[i];
|
||||
}
|
||||
if(showOutput) cout << " bool :";
|
||||
for(unsigned i=0;i<V.size();i++)
|
||||
{
|
||||
if(showOutput) printf(" %7.4f",(float)V[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::Run()
|
||||
{
|
||||
unsigned int cpt;
|
||||
for(cpt=0;data->read!=666;cpt++)
|
||||
{
|
||||
#ifdef __SHOW_NETWORK
|
||||
rSDL.setState(data->viewNetwork);
|
||||
if(!(cpt%16)) rSDL.refresh();
|
||||
#endif
|
||||
while(data->read==0) usleep(data->delay/2); // on attends que la voiture ait bougé
|
||||
if(data->read==666) break;
|
||||
|
||||
if(showOutput)
|
||||
{
|
||||
cout << "V = ";
|
||||
for(i=0;i<VSIZE;i++)
|
||||
{
|
||||
if(data->V[i]) cout << " ";
|
||||
else cout << "#";
|
||||
}
|
||||
}
|
||||
|
||||
if(data->action==SAVE_STATE)
|
||||
{
|
||||
cout << "Enregistrement de l'etat du reseau dans le fichier : " << STATE_FILE << endl;
|
||||
data->action=0;
|
||||
R.saveState(STATE_FILE);
|
||||
}
|
||||
else if(data->action==RELOAD_STATE)
|
||||
{
|
||||
cout << "Restauration de l'etat du reseau dans le fichier : " << STATE_FILE << endl;
|
||||
data->action=0;
|
||||
R.loadState(STATE_FILE);
|
||||
}
|
||||
if(data->APon==1)
|
||||
{
|
||||
pilot(data); // mode pilot automatique
|
||||
if(showOutput)
|
||||
{
|
||||
cout << " AP= ";
|
||||
for(i=0;i<TAILLERESULTAT;i++) printf(" %d",data->Res[i]);
|
||||
}
|
||||
}
|
||||
if(data->Neuron==1)
|
||||
{
|
||||
if(data->APon) // mode apprentissage (neurone + pilote)
|
||||
learnThis();
|
||||
else // neurone seul
|
||||
{
|
||||
neuronThis();
|
||||
}
|
||||
}
|
||||
if(showOutput) printf("\n");
|
||||
data->read=0;
|
||||
}
|
||||
cout << " EXIT AutoPilot ... " << endl;
|
||||
}
|
||||
void Game::preLearn()
|
||||
{
|
||||
// double learnAll(std::vector<bool *> inputs, std::vector<bool *> targets);
|
||||
std::vector<bool *> in;
|
||||
std::vector<bool *> r;
|
||||
int cpt=0;
|
||||
double erreur=0;
|
||||
|
||||
for(int i=0;i<PREtests;i++)
|
||||
{
|
||||
in.push_back(VoitureLearnI[i]);
|
||||
r.push_back(VoitureLearnR[i]);
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
++cpt;
|
||||
erreur += R.learnAll(in,r);
|
||||
if(erreur < LEARNACCEPT)
|
||||
break;
|
||||
if(cpt%100 == 0)
|
||||
{
|
||||
erreur/=100;
|
||||
cout << " : step " << cpt << " error:" << erreur << endl;
|
||||
erreur=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
void Game::preTest()
|
||||
{
|
||||
Utils u;
|
||||
std::vector<double> V;
|
||||
for(int i=0;i<PREtests;i++)
|
||||
{
|
||||
V=R.forward(VoitureLearnI[i]);
|
||||
cout << "pour : ";
|
||||
for(int j=0;j<64;j++) cout << VoitureLearnI[i][j] ;
|
||||
for(unsigned i=0;i<V.size();i++)
|
||||
cout << " [" << u.accept(V[i]) << "]";
|
||||
cout << " bool " ;
|
||||
for(unsigned i=0;i<V.size();i++)
|
||||
cout << " [" << V[i] << "] " ;
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
void Game::toggleShow(bool t)
|
||||
{
|
||||
showOutput=t;
|
||||
}
|
||||
44
server/game.h
Normal file
44
server/game.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef __GAME_H
|
||||
#define __GAME_H
|
||||
|
||||
#define VSIZE 64
|
||||
#include <unistd.h>
|
||||
#include "../InterfaceCpp/shmdata.h"
|
||||
|
||||
#include "../backprop/neurone.h"
|
||||
#include "../backprop/couche.h"
|
||||
#include "../backprop/inputCouche.h"
|
||||
#include "../backprop/synapse.h"
|
||||
#include "../backprop/synapseMatrix.h"
|
||||
#include "../backprop/reseau.h"
|
||||
#include "../backprop/Utils.h"
|
||||
|
||||
#define __SHOW_NETWORK
|
||||
|
||||
#ifdef __SHOW_NETWORK
|
||||
#include "reseauSDL.h"
|
||||
#endif
|
||||
|
||||
class Game{
|
||||
private :
|
||||
int shmid,i;
|
||||
bool neurError,showOutput;
|
||||
struct shmdata *data;
|
||||
Reseau R;
|
||||
#ifdef __SHOW_NETWORK
|
||||
ReseauSDL rSDL;
|
||||
#endif
|
||||
public :
|
||||
Game();
|
||||
void preLearn();
|
||||
void preTest();
|
||||
|
||||
void shmCreate();
|
||||
void pilot(struct shmdata *data);
|
||||
void learnThis();
|
||||
void neuronThis();
|
||||
void Run();
|
||||
void toggleShow(bool t);
|
||||
};
|
||||
|
||||
#endif
|
||||
BIN
server/game.o
Normal file
BIN
server/game.o
Normal file
Binary file not shown.
153
server/reseauSDL.cpp
Normal file
153
server/reseauSDL.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
#include "reseauSDL.h"
|
||||
|
||||
ReseauSDL::ReseauSDL ()
|
||||
{
|
||||
//font=SFont_InitFont(IMG_Load(FONT_PATH));
|
||||
couche1=0;
|
||||
couche2=0;
|
||||
couche3=0;
|
||||
width=800;
|
||||
height=600;
|
||||
R=NULL;
|
||||
active=0;
|
||||
}
|
||||
|
||||
void ReseauSDL::showScreen(int x=800, int y=600)
|
||||
{
|
||||
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);
|
||||
if( screen==NULL )
|
||||
{
|
||||
fprintf(stderr, "Could not create surface: %s\n", SDL_GetError());
|
||||
return ;
|
||||
}
|
||||
active=1;
|
||||
}
|
||||
|
||||
void ReseauSDL::hideScreen()
|
||||
{
|
||||
SDL_FreeSurface(screen);
|
||||
}
|
||||
|
||||
void ReseauSDL::setReseau(Reseau *r)
|
||||
{
|
||||
R=r;
|
||||
couche1=r->Icouche.getNumber();
|
||||
couche2=r->Hcouche.getNumber();
|
||||
couche3=r->Ocouche.getNumber();
|
||||
}
|
||||
void ReseauSDL::drawNeuron(int couche, int neur)
|
||||
{
|
||||
SDL_Rect r;
|
||||
char red;
|
||||
char green;
|
||||
double syn;
|
||||
r.x= 100 + (300*(couche-1));
|
||||
if(couche==1)
|
||||
{
|
||||
r.y= (600*(neur+1)) / (couche1+1) ;
|
||||
for(int i=0;i<couche2;i++)
|
||||
{
|
||||
red=0;
|
||||
green=0;
|
||||
syn=R->Icouche.getSynapse(neur,i).getWeight();
|
||||
//cout << "DA - " << syn ;
|
||||
if(syn<0.0)
|
||||
{
|
||||
if(syn<-2.0) syn=-2.0;
|
||||
syn=syn*-1.0;
|
||||
syn*=128.0;
|
||||
red=(char)syn;
|
||||
}
|
||||
else if(syn>0.0)
|
||||
{
|
||||
if(syn>2.0) syn=2.0;
|
||||
syn*=128.0;
|
||||
green=(char)syn;
|
||||
}
|
||||
//cout << " r=" << (int)red << " g=" << (int)green << endl;
|
||||
DrawLine(screen, r.x , r.y , 100+(300*couche) , (600*(i+1))/(couche2+1) , red,green,0);
|
||||
}
|
||||
}
|
||||
if(couche==2)
|
||||
{
|
||||
r.y=(600*(neur+1))/(couche2+1);
|
||||
for(int i=0;i<couche3;i++)
|
||||
{
|
||||
red=0;
|
||||
green=0;
|
||||
syn=R->Hcouche.getSynapse(neur,i).getWeight();
|
||||
if(syn<0.0)
|
||||
{
|
||||
if(syn<-2.0) syn=-2.0;
|
||||
syn=syn*-1.0;
|
||||
syn*=128.0;
|
||||
red=(char)syn;
|
||||
}
|
||||
else if(syn>0.0)
|
||||
{
|
||||
if(syn>2.0) syn=2.0;
|
||||
syn*=128.0;
|
||||
green=(char)syn;
|
||||
}
|
||||
//cout << " r=" << (int)red << " g=" << (int)green << endl;
|
||||
DrawLine(screen, r.x , r.y , 100+(300*couche) , (600*(i+1))/(couche3+1) , red,green,0);
|
||||
}
|
||||
}
|
||||
if(couche==3)
|
||||
{
|
||||
r.y= ((600*(neur+1))/(couche3+1));
|
||||
}
|
||||
r.x-=2;
|
||||
r.y-=2;
|
||||
r.w=5;
|
||||
r.h=5;
|
||||
SDL_FillRect(screen,&r, SDL_MapRGB(screen->format, 0,0,255));
|
||||
}
|
||||
|
||||
bool ReseauSDL::getState()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
void ReseauSDL::setState(bool st)
|
||||
{
|
||||
if(st==active) return;
|
||||
if(st==true)
|
||||
{
|
||||
showScreen();
|
||||
active=st;
|
||||
}
|
||||
else
|
||||
{
|
||||
hideScreen();
|
||||
active=st;
|
||||
SDL_Quit();
|
||||
}
|
||||
}
|
||||
void ReseauSDL::refresh()
|
||||
{
|
||||
if(active)
|
||||
{
|
||||
SDL_Rect r;
|
||||
r.x=0;
|
||||
r.y=0;
|
||||
r.w=800;
|
||||
r.h=600;
|
||||
SDL_FillRect(screen,&r, SDL_MapRGB(screen->format, 255,255,255));
|
||||
for(int i=0;i<couche1;i++) drawNeuron(1,i);
|
||||
for(int i=0;i<couche2;i++) drawNeuron(2,i);
|
||||
for(int i=0;i<couche3;i++) drawNeuron(3,i);
|
||||
SDL_Flip (screen);
|
||||
}
|
||||
}
|
||||
/*
|
||||
void ReseauSDL::redraw_synapses(Reseau &R)
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
*/
|
||||
49
server/reseauSDL.h
Normal file
49
server/reseauSDL.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef __RESEAU_SDL
|
||||
#define __RESEAU_SDL
|
||||
#include <iostream>
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
#include <time.h>
|
||||
#include "../InterfaceCpp/sdlcommon.h"
|
||||
#include "../InterfaceCpp/SFont.h"
|
||||
|
||||
#include "../backprop/neurone.h"
|
||||
#include "../backprop/couche.h"
|
||||
#include "../backprop/inputCouche.h"
|
||||
#include "../backprop/synapse.h"
|
||||
#include "../backprop/synapseMatrix.h"
|
||||
#include "../backprop/reseau.h"
|
||||
|
||||
#define FONT_PATH "InterfaceCpp/font.png"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class ReseauSDL
|
||||
{
|
||||
private:
|
||||
SDL_Surface* screen;
|
||||
int couche1;
|
||||
int couche2;
|
||||
int couche3;
|
||||
int width;
|
||||
int height;
|
||||
bool active;
|
||||
Reseau *R;
|
||||
//SFont_Font* font;
|
||||
|
||||
public:
|
||||
ReseauSDL();
|
||||
// ~ReseauSDL();
|
||||
void setReseau(Reseau *r);
|
||||
void putPixel(int , int , char, char, char);
|
||||
void refresh();
|
||||
//void redraw_synapses(Reseau &R);
|
||||
void drawNeuron(int couche, int neur);
|
||||
void showScreen(int x, int y);
|
||||
void hideScreen();
|
||||
bool getState();
|
||||
void setState(bool );
|
||||
};
|
||||
|
||||
#endif
|
||||
BIN
server/reseauSDL.o
Normal file
BIN
server/reseauSDL.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user