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

fire.c

Blame
  • fire.c 4.46 KiB
    #include "fire.h"
    #include "map.h"
    
    listchainfire_t fireList;
    int markov[SIZEMARKOV][SIZEMARKOV];
    
    listchainfire_t initFire (void)
    {
        return NULL;
    }
    
    
    booleen_t emptyListFire(listchainfire_t listFire)
    {
        booleen_t result = false;
    
        if (listFire==NULL)
        {
            result=true;
        }
        return (result);
    }
    
    listchainfire_t insertAheadFire(fire_t fire,listchainfire_t listFire)
    {
        chainfire_t *m;
        m=(chainfire_t*)malloc(sizeof(chainfire_t));
                
        if (m==NULL)
        {
            printf("problème d'allocation \n");
            exit(1);
        }
        if (!searchFire(listFire,fire.x,fire.y)){
        m->fire=fire;
        m->next= listFire;
        listFire=m;}
    
        return listFire;
    
    }
    
    listchainfire_t startFire(listchainfire_t listFire,int numberFire, int mapSize){
    
        int i; 
        int xFire=0;
        int yFire=0;
        srand(time(NULL));
    
        fire_t fire;
    
        if (emptyListFire(listFire)){
            for (i=0;i<numberFire;i++){
                
                xFire= rand()%mapSize;
    
                yFire= rand()%mapSize;
                //printf("xf:%d,yf:%d\n",xFire,yFire);
                fire.x= xFire;
                fire.y= yFire; 
                fire.state=1;
    
                listFire=insertAheadFire(fire, listFire); 
                
            }
        }
        return (listFire);
    }