Skip to content
Snippets Groups Projects
Select Git revision
  • 564eaaa5682d0147719c27614e9e4e0d07203e7a
  • main default
  • qlearn-4
  • qlearning5
  • qlearn5
  • render
  • qlearn
  • ball
  • fire
  • player
10 results

qlearn.c

Blame
  • qlearn.c 2.48 KiB
    #include "qlearn.h"
    
    void moveAgent(agent_t * agent, int choice){
        switch (choice)
        {
        case BACK:
            agent->x += 1*agent->speed; //Avancer 
            break;
    
        case FOWARD:
            agent->x -= 1*agent->speed; // reculer 
            break;
    
        case UP:
            agent->y += 1*agent->speed;
            break;
    
        case DOWN:
            agent->y -= 1*agent->speed;
            break;
        case WAIT: 
            break; 
        }
    }
    
    float ***** allocateAndInitiateQ(){
        int i,j,k,l,m;
        
        float ***** q = malloc(sizeof(float ****) * NUMBER_ZONE_RECEIVER); /// alloc player zone 
        if (q==NULL)
        {
            printf("problème d'allocation \n");
            exit(1);
        }
    
        for(i = 0; i <  NUMBER_ZONE_RECEIVER; i++){  
            q[i] = malloc(sizeof(float ***) * NUMBER_ZONE_SHOOTER ); // alloc shooter zone 
            if (q[i]==NULL)
            {
                printf("problème d'allocation \n");            
                exit(1);
            }
    
            for(j = 0; j< NUMBER_ZONE_SHOOTER; j++){
                q[i][j] = malloc(sizeof(float **) * 3 ); // alloc angle hauteur 
    
                if (q[i][j]==NULL)
                {
                    printf("problème d'allocation \n");            
                    exit(1);
                }
    
                for(k = 0; k <3 ; k++){
                    q[i][j][k] = malloc(sizeof(float *) * 5 ); // alloc angle plat 
    
                    if (q[i][j][k]==NULL)
                    {
                        printf("problème d'allocation \n");            
                        exit(1);
                    }
                    for(l = 0; l<5 ; l++){
                        q[i][j][k][l] = malloc(sizeof(float ) * 5); //alloc action 
    
                        if (q[i][j][k][l]==NULL)
                        {
                            printf("problème d'allocation \n");            
                            exit(1);
                        }
                        for (m=0;m <5;m++){
                            q[i][j][k][l][m]=0;