コード例 #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);
 }
コード例 #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;
 }
コード例 #3
0
 //calculate ability to pollute
 public bool CanPollute(Patch patch)
 {
     return (patch.Pollution < (Income - patch.Vegetation)
         && MyPatch.Pollution < Analyze(patch));
 }
コード例 #4
0
 public bool CanGrow(Patch patch)
 {
     return (patch.Vegetation < (Income - patch.Pollution)
         && MyPatch.Pollution < PEC + (MyPatch.Vegetation + 1));
 }
コード例 #5
0
 public int AnalyzePatch(Patch patch)
 {
     return Income - patch.Pollution;
 }
コード例 #6
0
 public int Analyze(Patch patch)
 {
     return PecIntercept + patch.Vegetation;
 }