Ejemplo n.º 1
0
        public double rankGrid(Grid board)
        {
            double rank = 0;
            int largest = 0;

            PriorityQueue<Group> moves = board.calculateGroupsQueue();
            if(!moves.isEmpty)
                largest = moves.Dequeue().Bubbles;

            int groups = 0;
            int singles = 0;
            int remaining = 0;

            while (!(moves.isEmpty) && (moves.Peek().Bubbles > 1))
            {
                groups++;
                remaining += moves.Dequeue().Bubbles;
            }

            singles = moves.Count;
            remaining += singles;

             if(board.checkWin())
             	rank = (board.X * board.X) *1000;
             else if (board.checkLocked())
             	rank  = 0 - singles;
             else
             	rank = (remaining - singles) + largest;

              	return rank;
        }
Ejemplo n.º 2
0
        public double rankGrid(Grid board)
        {
            double rank    = 0;
            int    largest = 0;

            PriorityQueue <Group> moves = board.calculateGroupsQueue();

            if (!moves.isEmpty)
            {
                largest = moves.Dequeue().Bubbles;
            }

            int groups    = 0;
            int singles   = 0;
            int remaining = 0;

            while (!(moves.isEmpty) && (moves.Peek().Bubbles > 1))
            {
                groups++;
                remaining += moves.Dequeue().Bubbles;
            }

            singles    = moves.Count;
            remaining += singles;

            if (board.checkWin())
            {
                rank = (board.X * board.X) * 1000;
            }
            else if (board.checkLocked())
            {
                rank = 0 - singles;
            }
            else
            {
                rank = (remaining - singles) + largest;
            }


            return(rank);
        }