Skip to content
Snippets Groups Projects
Commit 6134a63c authored by Your Name's avatar Your Name
Browse files

fonction de MAJ de la map

parent 5a08c2ce
No related branches found
No related tags found
1 merge request!1entrer/sortir de fourmilliere, changer de case, ramasser bouffe, bouffe...
......@@ -25,9 +25,9 @@ class CaseMap
//bool trueBlocFalseBouffe;
//int niveauBloc_OU_niveauBouffe; // niveau = 0 --> case vide
int PathtoAlert[4]; //0
int PathtoFood[4]; //1
int PathtoAnthill[4]; //2
int PathtoAlert[TAILLEPATHPHEROMONE]; //0
int PathtoFood[TAILLEPATHPHEROMONE]; //1
int PathtoAnthill[TAILLEPATHPHEROMONE]; //2
public:
CaseMap();
......
No preview for this file type
......@@ -27,6 +27,9 @@ const int LONGUEURMAP = 20;
const int LARGEURMAP = 20;
const int TAILLEPATHPHEROMONE = 4;
const int QUANTITYBOUFFERECHARGEMENTMAP = 50000;
const int MINIMUMDECASESRECHARGED = 5;
const int NBRFOURMILLIERES = 5;
const int NBRMAXFOURMIS = 200;
......
......@@ -102,3 +102,54 @@ void Manager::placerFourmilliere(Fourmilliere* fourmilliereNonPlaced)
}
}
void Manager::majMapBouffe()
{
int bouffePourRajout = QUANTITYBOUFFERECHARGEMENTMAP;
while(bouffePourRajout > 0)
{
int iCaseRecharged = uniform_int(0, LONGUEURMAP - 1);
int jCaseRecharged = uniform_int(0, LARGEURMAP - 1);
int quantityBouffeRajouted = uniform_int(0, QUANTITYBOUFFERECHARGEMENTMAP / MINIMUMDECASESRECHARGED);
if(quantityBouffeRajouted > bouffePourRajout)
{
quantityBouffeRajouted = bouffePourRajout;
}
map[iCaseRecharged][jCaseRecharged].SetBouffeQuantity(map[iCaseRecharged][jCaseRecharged].GetBouffeQuantity() + quantityBouffeRajouted);
bouffePourRajout -= quantityBouffeRajouted;
//cout << quantityBouffeRajouted << "\n";
}
}
void Manager::majMapPheromone()
{
for(int i = 0; i < LONGUEURMAP; i++)
{
for(int j = 0; j < LARGEURMAP; j++)
{
for(int indicePath = 0; indicePath < TAILLEPATHPHEROMONE; indicePath++)
{
if(map[i][j].GetPathtoAlert(indicePath) > 0)
{
map[i][j].SetPathtoAlert(indicePath, map[i][j].GetPathtoAlert(indicePath) - 1);
//cout << "yaa\n";
}
if(map[i][j].GetPathtoAnthill(indicePath) > 0)
{
map[i][j].SetPathtoAnthill(indicePath, map[i][j].GetPathtoAnthill(indicePath) - 1);
//cout << "yaa\n";
}
if(map[i][j].GetPathtoFood(indicePath) > 0)
{
map[i][j].SetPathtoFood(indicePath, map[i][j].GetPathtoFood(indicePath) - 1);
//cout << "yaa\n";
}
}
}
}
}
......@@ -20,6 +20,8 @@ class Manager
void initialiserMap();
void afficherMap();
void placerFourmilliere(Fourmilliere*);
void majMapBouffe();
void majMapPheromone();
};
......
......@@ -105,6 +105,9 @@ int main()
cout << "log10 de 1200 : " << (int)log10(9) << "\n";
manager.afficherMap();
manager.majMapBouffe();
manager.majMapPheromone();
manager.afficherMap();
/*
cout << newFourmilliere.GetNbrfourmisLoyales() << "\n\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment