//---------------------------------------------------------------------------------
 //constructor
 public Agent(Patch patch, int income = 0, int pec = 50)
 {
     Income = income;
     MyPatch = patch;
     PecIntercept = pec;
     patch.IsEmpty = false;
     PEC = Analyze(patch);
 }
 //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;
 }
 //calculate ability to pollute
 public bool CanPollute(Patch patch)
 {
     return (patch.Pollution < (Income - patch.Vegetation)
         && MyPatch.Pollution < Analyze(patch));
 }
 public bool CanGrow(Patch patch)
 {
     return (patch.Vegetation < (Income - patch.Pollution)
         && MyPatch.Pollution < PEC + (MyPatch.Vegetation + 1));
 }
 public int AnalyzePatch(Patch patch)
 {
     return Income - patch.Pollution;
 }
 public int Analyze(Patch patch)
 {
     return PecIntercept + patch.Vegetation;
 }