Ejemplo n.º 1
0
        public int Compare(ScoreCollection other, PlayerType player)
        {
            switch (player)
            {
            case PlayerType.Hero1: return(other.score1.ToUInt32().CompareTo(score1.ToUInt32()));

            case PlayerType.Hero2: return(other.score2.ToUInt32().CompareTo(score2.ToUInt32()));

            case PlayerType.Hero3: return(other.score3.ToUInt32().CompareTo(score3.ToUInt32()));

            case PlayerType.Hero4: return(other.score4.ToUInt32().CompareTo(score4.ToUInt32()));

            case PlayerType.None:
            default:
                throw new NotSupportedException(string.Format("PlayerType '{0}' is not supported.", player));
            }
        }
Ejemplo n.º 2
0
        /// <summary>If any of the alpha's of the opponents is worse then the test score: break.
        ///
        /// Otherwise update if a better alpha is found for the player.
        /// </summary>
        public bool ContinueProccesingAlphas(ScoreCollection test, PlayerType player, out ScoreCollection alphasOut)
        {
            foreach (var other in PlayerTypes.Other[player])
            {
                if (Compare(test, other) < 0)
                {
                    alphasOut = this;
                    return(false);
                }
            }

            IScore s1 = score1;
            IScore s2 = score2;
            IScore s3 = score3;
            IScore s4 = score4;

            switch (player)
            {
            case PlayerType.Hero1: if (Compare(test, player) > 0)
                {
                    s1 = test.score1;
                }
                break;

            case PlayerType.Hero2: if (Compare(test, player) > 0)
                {
                    s2 = test.score2;
                }
                break;

            case PlayerType.Hero3: if (Compare(test, player) > 0)
                {
                    s3 = test.score3;
                }
                break;

            case PlayerType.Hero4: if (Compare(test, player) > 0)
                {
                    s4 = test.score4;
                }
                break;
            }
            alphasOut = new ScoreCollection(s1, s2, s3, s4);
            return(true);
        }
Ejemplo n.º 3
0
 public override int Compare(ScoreCollection x, ScoreCollection y)
 {
     return(x.Compare(y, PlayerType.Hero4));
 }