Skip to content
Snippets Groups Projects
Commit 0a42530f authored by maberet's avatar maberet
Browse files

commit pour récup des fonctions lagrange

parent b275e90e
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ agent_t * initAgent (){ ...@@ -6,7 +6,7 @@ agent_t * initAgent (){
printf("erreur alloc\n "); printf("erreur alloc\n ");
exit (1); exit (1);
} }
agent->x=(16+rand()%16)*BLOCK_SIZE; agent->x=(16+rand()%14)*BLOCK_SIZE;
agent->y=(1+rand()%14)*BLOCK_SIZE; agent->y=(1+rand()%14)*BLOCK_SIZE;
agent->high=2*BLOCK_SIZE; agent->high=2*BLOCK_SIZE;
agent->weight=2*BLOCK_SIZE; agent->weight=2*BLOCK_SIZE;
...@@ -92,7 +92,6 @@ float ***** allocateAndInitiateQ(){ ...@@ -92,7 +92,6 @@ float ***** allocateAndInitiateQ(){
return q; return q;
} }
// attention il manque 3 lignes
void writeQ(float *****Q){ void writeQ(float *****Q){
int i, j, k, l, m ; int i, j, k, l, m ;
FILE * fp = fopen("q.txt", "w+"); FILE * fp = fopen("q.txt", "w+");
...@@ -247,6 +246,29 @@ int setReward(int xAgent, int yAgent, int dropZone){ ...@@ -247,6 +246,29 @@ int setReward(int xAgent, int yAgent, int dropZone){
reward=1; reward=1;
} }
return (reward); return (reward);
} }
float defineAngle (int xCanon, int yCanon , int xDropPoint, int yDropPoint){
float distance;
float angleSin;
distance= sqrtf( powf((float)(xDropPoint-xCanon),2)+powf((float)(yDropPoint-yCanon),2));
angleSin = asinf(distance/(xDropPoint-xCanon));
return angleSin;
}
void traningAgent ( int numberRun, int numberStep, float *****Q) {
int i ;
int action;
point_t canon ;
point_t dropPoint ;
while (numberRun>0){
canon=initPoint(0);
dropPoint= initPoint(1);
for (i=0; i< numberStep;i++){
}
}
}
...@@ -37,6 +37,12 @@ typedef struct line { ...@@ -37,6 +37,12 @@ typedef struct line {
}line_t,*ptline_t; }line_t,*ptline_t;
typedef struct point{
int x;
int y;
} point_t ;
agent_t* initAgent ( ); agent_t* initAgent ( );
void moveAgent(agent_t * agent, int choice); void moveAgent(agent_t * agent, int choice);
float ***** allocateAndInitiateQ(); float ***** allocateAndInitiateQ();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment