示例#1
0
 public int CompareTo(ActionValuePair <A> pair)
 {
     if (value < pair.value)
     {
         return(1);
     }
     else if (value > pair.value)
     {
         return(-1);
     }
     else
     {
         return(0);
     }
 }
示例#2
0
        /**
         * Orders actions with respect to the number of potential win positions
         * which profit from the action.
         */
        public override ICollection <int> orderActions(ConnectFourState state,
                                                       ICollection <int> actions, string player, int depth)
        {
            ICollection <int> result = actions;

            if (depth == 0)
            {
                ICollection <ActionValuePair <int> > actionEstimates
                    = CollectionFactory.CreateQueue <ActionValuePair <int> >();
                foreach (int action in actions)
                {
                    actionEstimates.Add(ActionValuePair <int> .createFor(action,
                                                                         state.analyzePotentialWinPositions(action)));
                }
                actionEstimates.Sort(new List <ActionValuePair <int> > .Comparer());
                result = CollectionFactory.CreateQueue <int>();
                foreach (ActionValuePair <int> pair in actionEstimates)
                {
                    result.Add(pair.getAction());
                }
            }
            return(result);
        }