Esempio n. 1
0
 //---------------------------------------------------------------------------------
 //constructor
 public Agent(Patch patch, int income = 0, int pec = 50)
 {
     Income = income;
     MyPatch = patch;
     PecIntercept = pec;
     patch.IsEmpty = false;
     PEC = Analyze(patch);
 }
Esempio n. 2
0
 //search patchlist and determine which patch to move to
 public bool Move(ArrayList patchList)
 {
     ArrayList tmpList = new ArrayList(patchList);
     Patch patch;
     // search for an empty patch
     for (int i = 0; i < patchList.Count; i++)
     {
         patch = ((Patch)(tmpList.ToArray()[rand.Next(tmpList.Count)]));
         if (patch.IsEmpty && CanPollute(patch))
         {
             MyPatch.IsEmpty = true;
             MyPatch = patch;
             MyPatch.IsEmpty = false;
             return true;
         }
         tmpList.Remove(patch);
     }
     return false;
 }
Esempio n. 3
0
 //calculate ability to pollute
 public bool CanPollute(Patch patch)
 {
     return (patch.Pollution < (Income - patch.Vegetation)
         && MyPatch.Pollution < Analyze(patch));
 }
Esempio n. 4
0
 public bool CanGrow(Patch patch)
 {
     return (patch.Vegetation < (Income - patch.Pollution)
         && MyPatch.Pollution < PEC + (MyPatch.Vegetation + 1));
 }
Esempio n. 5
0
 public int AnalyzePatch(Patch patch)
 {
     return Income - patch.Pollution;
 }
Esempio n. 6
0
 public int Analyze(Patch patch)
 {
     return PecIntercept + patch.Vegetation;
 }