Exemplo n.º 1
0
 public static Utility Min(string[] roles, int roleIndex)
 {
     var result = new Utility(roles);
     for (int i = 0; i < roles.Length; i++)
     {
         result.scores[i] = i == roleIndex ? float.MinValue : float.MaxValue;
     }
     return result;
 }
Exemplo n.º 2
0
 public bool BetterThan(Utility other, int forPlayerIndex)
 {
     float myUtility = 0f;
     float myUtilityOther = 0f;
     float opponentsUtility = 0f;
     float opponentsUtilityOther = 0f;
     for (int i = 0; i < scores.Length; i++)
     {
         if (i == forPlayerIndex)
         {
             myUtility = scores[i];
             myUtilityOther = other.scores[i];
         }
         else
         {
             opponentsUtility += scores[i];
             opponentsUtilityOther += other.scores[i];
         }
     }
     if (myUtility > myUtilityOther) return true;
     if (myUtility < myUtilityOther) return false;
     return opponentsUtility > opponentsUtilityOther;
 }