コード例 #1
0
ファイル: AdaptiveSelector.cs プロジェクト: xiangnanyue/DDD
 public AdaptiveSelector(ISelectionMethod initialGoal, String formattedMatrixString)
 {
     _templateMatrix = new CpeMatrix();
     _templateMatrix.LoadCpeMatrix(formattedMatrixString);
     _currentGoal      = initialGoal;
     _selectCurrentCpe = new MaintainMethod();
 }
コード例 #2
0
ファイル: AdaptiveSelector.cs プロジェクト: wshanshan/DDD
 public AdaptiveSelector(ISelectionMethod initialGoal, String formattedMatrixString)
 {
     _templateMatrix = new CpeMatrix();
     _templateMatrix.LoadCpeMatrix(formattedMatrixString);
     _currentGoal = initialGoal;
     _selectCurrentCpe = new MaintainMethod();
 }
コード例 #3
0
ファイル: MaintainMethod.cs プロジェクト: wshanshan/DDD
 public override CellRange SelectNextCell(CpeMatrix matrix, double cpe1, double cpe2, List<int> ignoreCells, int failedAttempts)
 {
     if (ignoreCells != null)
     {
         
         List<CellRange> possibleCells = matrix.GetCellsByCpe(cpe1, cpe2, failedAttempts);
         //go through each possible cell looking for those not already ignored.
         foreach (CellRange cr in possibleCells)
         {
             if (!ignoreCells.Contains(cr.CellNumber))
                 return cr.Copy();
         }
         return null;
     }
     CellRange current = matrix.GetCellByCpe(cpe1, cpe2);
     return current; //because we're maintaining, keep in their cpe cell
 }
コード例 #4
0
ファイル: MatrixControl.xaml.cs プロジェクト: xiangnanyue/DDD
        internal void SetMatrix(AdaptiveSelector.CpeMatrix cpeMatrix)
        {
            labelBlank.Visibility = System.Windows.Visibility.Collapsed;
            int    cols      = cpeMatrix.GetColumnCount();
            int    rows      = cpeMatrix.GetRowCount();
            double colWidth  = this.Width / (cols - 1);
            double rowHeight = this.Height / (rows - 1);

            ColumnDefinition cd;
            RowDefinition    rd;

            for (int x = 0; x < cols; x++)
            {
                cd       = new ColumnDefinition();
                cd.Width = new GridLength(colWidth, GridUnitType.Star);
                mainGrid.ColumnDefinitions.Add(cd);
            }
            for (int x = 0; x < rows; x++)
            {
                rd        = new RowDefinition();
                rd.Height = new GridLength(rowHeight, GridUnitType.Star);
                mainGrid.RowDefinitions.Add(rd);
            }

            SingleItemBox box;
            CellRange     c;

            for (int y = 0; y < rows; y++)
            {
                for (int x = 0; x < cols; x++)
                {
                    c = cpeMatrix.GetCellByIndex(y, x);
                    Console.WriteLine(String.Format("Making item '{0}' at x={1};y={2};", c.CellNumber, x, y));
                    box = new SingleItemBox(c);
                    box.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    box.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                    box.Name = "box_" + c.CellNumber;
                    Grid.SetColumn(box, x);
                    Grid.SetRow(box, y);
                    _workaround[c.CellNumber] = box;
                    mainGrid.Children.Add(box);
                }
            }
        }
コード例 #5
0
ファイル: MaintainMethod.cs プロジェクト: xiangnanyue/DDD
        public override CellRange SelectNextCell(CpeMatrix matrix, double cpe1, double cpe2, List <int> ignoreCells, int failedAttempts)
        {
            if (ignoreCells != null)
            {
                List <CellRange> possibleCells = matrix.GetCellsByCpe(cpe1, cpe2, failedAttempts);
                //go through each possible cell looking for those not already ignored.
                foreach (CellRange cr in possibleCells)
                {
                    if (!ignoreCells.Contains(cr.CellNumber))
                    {
                        return(cr.Copy());
                    }
                }
                return(null);
            }
            CellRange current = matrix.GetCellByCpe(cpe1, cpe2);

            return(current); //because we're maintaining, keep in their cpe cell
        }
コード例 #6
0
 public virtual CellRange SelectNextCell(CpeMatrix matrix, double cpe1, double cpe2, List <int> ignoreCells, int failedAttempts)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
        public override CellRange SelectNextCell(CpeMatrix matrix, double cpe1, double cpe2, List <int> ignoreCells, int failedAttempts)
        {
            CellRange        current       = matrix.GetCellByCpe(cpe1, cpe2);
            int              x             = current.Xindex;
            int              y             = current.Yindex;
            List <CellRange> possibleCells = new List <CellRange>();

            if (Math.Abs(cpe1 - cpe2) >= Threshold)
            {
                if (cpe1 > cpe2)
                {
                    //focus on CPE2
                    x = current.Xindex;
                    y = current.Yindex;
                    x = Math.Min(x + 1, matrix.GetColumnCount() - 1);
                }
                else
                {
                    //focus on CPE1
                    x = current.Xindex;
                    y = current.Yindex;
                    y = Math.Min(y + 1, matrix.GetRowCount() - 1);
                }
            }
            else
            {
                //focus on both
                x = current.Xindex;
                y = current.Yindex;
                x = Math.Min(x + 1, matrix.GetColumnCount() - 1);
                y = Math.Min(y + 1, matrix.GetRowCount() - 1);
            }


            if (ignoreCells != null)
            {
                possibleCells = matrix.GetCellsByIndex(y, x, failedAttempts);
                foreach (CellRange cr in possibleCells)
                {
                    if (!ignoreCells.Contains(cr.CellNumber))
                    {
                        return(cr.Copy());
                    }
                }
                return(null);
            }
            return(matrix.GetCellByIndex(y, x));

            /*
             * //then move appropriately
             * if (Math.Abs(cpe1 - cpe2) >= Threshold)
             * {
             *  if (cpe1 > cpe2)
             *  {
             *      //focus on CPE2
             *      int x = current.Xindex;
             *      int y = current.Yindex;
             *      x = Math.Min(x + 1, matrix.GetColumnCount() - 1);
             *      return matrix.GetCellByIndex(y, x);
             *  }
             *  else
             *  {
             *      //focus on CPE1
             *      int x = current.Xindex;
             *      int y = current.Yindex;
             *      y = Math.Min(y + 1, matrix.GetRowCount() - 1);
             *      return matrix.GetCellByIndex(y, x);
             *  }
             * }
             * else
             * {
             *  //focus on both
             *  int x = current.Xindex;
             *  int y = current.Yindex;
             *  x = Math.Min(x + 1, matrix.GetColumnCount()-1);
             *  y = Math.Min(y + 1, matrix.GetRowCount()-1);
             *  return matrix.GetCellByIndex(y, x);
             * }
             * return null;*/
        }
コード例 #8
0
ファイル: ChallengeMethod.cs プロジェクト: wshanshan/DDD
        public override CellRange SelectNextCell(CpeMatrix matrix, double cpe1, double cpe2, List<int> ignoreCells, int failedAttempts)
        {
            CellRange current = matrix.GetCellByCpe(cpe1, cpe2);
            int x = current.Xindex;
            int y = current.Yindex;
            List<CellRange> possibleCells = new List<CellRange>();
            if (Math.Abs(cpe1 - cpe2) >= Threshold)
            {
                if (cpe1 > cpe2)
                {
                    //focus on CPE2
                    x = current.Xindex;
                    y = current.Yindex;
                    x = Math.Min(x + 1, matrix.GetColumnCount() - 1);
                    
                }
                else
                {
                    //focus on CPE1
                    x = current.Xindex;
                    y = current.Yindex;
                    y = Math.Min(y + 1, matrix.GetRowCount() - 1);
                    
                }
            }
            else
            {
                //focus on both
                x = current.Xindex;
                y = current.Yindex;
                x = Math.Min(x + 1, matrix.GetColumnCount() - 1);
                y = Math.Min(y + 1, matrix.GetRowCount() - 1);
                
            }


            if (ignoreCells != null)
            {
                possibleCells = matrix.GetCellsByIndex(y, x, failedAttempts);
                foreach (CellRange cr in possibleCells)
                {
                    if (!ignoreCells.Contains(cr.CellNumber))
                        return cr.Copy();
                }
                return null;
            }
            return matrix.GetCellByIndex(y, x);
            /*
            //then move appropriately
            if (Math.Abs(cpe1 - cpe2) >= Threshold)
            {
                if (cpe1 > cpe2)
                {
                    //focus on CPE2
                    int x = current.Xindex;
                    int y = current.Yindex;
                    x = Math.Min(x + 1, matrix.GetColumnCount() - 1);
                    return matrix.GetCellByIndex(y, x);
                }
                else
                {
                    //focus on CPE1
                    int x = current.Xindex;
                    int y = current.Yindex;
                    y = Math.Min(y + 1, matrix.GetRowCount() - 1);
                    return matrix.GetCellByIndex(y, x);
                }
            }
            else
            { 
                //focus on both
                int x = current.Xindex;
                int y = current.Yindex;
                x = Math.Min(x + 1, matrix.GetColumnCount()-1);
                y = Math.Min(y + 1, matrix.GetRowCount()-1);
                return matrix.GetCellByIndex(y, x);
            }
            return null;*/
        }
コード例 #9
0
        public override CellRange SelectNextCell(CpeMatrix matrix, double cpe1, double cpe2, List <int> ignoreCells, int failedAttempts)
        {
            CellRange current;

            if (ignoreCells != null)
            {
                current = matrix.GetCellByCpe(cpe1, cpe2);
                List <CellRange> possibleCells;// = matrix.GetCellsByCpe(cpe1, cpe2, failedAttempts);
                if (Math.Abs(cpe1 - cpe2) >= Threshold)
                {
                    if (cpe1 > cpe2)
                    {
                        //focus on CPE2
                        int x = current.Xindex;
                        int y = current.Yindex;
                        x             = Math.Max(x - 1, 0);
                        possibleCells = matrix.GetCellsByIndex(y, x, failedAttempts);
                    }
                    else
                    {
                        //focus on CPE1
                        int x = current.Xindex;
                        int y = current.Yindex;
                        y             = Math.Max(y - 1, 0);
                        possibleCells = matrix.GetCellsByIndex(y, x, failedAttempts);
                    }
                }
                else
                {
                    //focus on both
                    int x = current.Xindex;
                    int y = current.Yindex;
                    x             = Math.Max(x - 1, 0);
                    y             = Math.Max(y - 1, 0);
                    possibleCells = matrix.GetCellsByIndex(y, x, failedAttempts);
                }
                //go through each possible cell looking for those not already ignored.
                foreach (CellRange cr in possibleCells)
                {
                    if (!ignoreCells.Contains(cr.CellNumber))
                    {
                        return(cr.Copy());
                    }
                }
                return(null);
            }
            current = matrix.GetCellByCpe(cpe1, cpe2);
            //then move appropriately
            if (Math.Abs(cpe1 - cpe2) >= Threshold)
            {
                if (cpe1 > cpe2)
                {
                    //focus on CPE2
                    int x = current.Xindex;
                    int y = current.Yindex;
                    x = Math.Max(x - 1, 0);
                    return(matrix.GetCellByIndex(y, x));
                }
                else
                {
                    //focus on CPE1
                    int x = current.Xindex;
                    int y = current.Yindex;
                    y = Math.Max(y - 1, 0);
                    return(matrix.GetCellByIndex(y, x));
                }
            }
            else
            {
                //focus on both
                int x = current.Xindex;
                int y = current.Yindex;
                x = Math.Max(x - 1, 0);
                y = Math.Max(y - 1, 0);
                return(matrix.GetCellByIndex(y, x));
            }
            return(null);
        }
コード例 #10
0
ファイル: BaseMethod.cs プロジェクト: wshanshan/DDD
 public virtual CellRange SelectNextCell(CpeMatrix matrix, double cpe1, double cpe2, List<int> ignoreCells, int failedAttempts)
 {
     
     throw new NotImplementedException();
 }
コード例 #11
0
ファイル: ConsolidateMethod.cs プロジェクト: wshanshan/DDD
 public override CellRange SelectNextCell(CpeMatrix matrix, double cpe1, double cpe2, List<int> ignoreCells, int failedAttempts)
 {
     CellRange current;
     if (ignoreCells != null)
     {
         current = matrix.GetCellByCpe(cpe1, cpe2);
         List<CellRange> possibleCells;// = matrix.GetCellsByCpe(cpe1, cpe2, failedAttempts);
         if (Math.Abs(cpe1 - cpe2) >= Threshold)
         {
             if (cpe1 > cpe2)
             {
                 //focus on CPE2
                 int x = current.Xindex;
                 int y = current.Yindex;
                 x = Math.Max(x - 1, 0);
                 possibleCells = matrix.GetCellsByIndex(y, x, failedAttempts);
             }
             else
             {
                 //focus on CPE1
                 int x = current.Xindex;
                 int y = current.Yindex;
                 y = Math.Max(y - 1, 0);
                 possibleCells = matrix.GetCellsByIndex(y, x, failedAttempts);
             }
         }
         else
         {
             //focus on both
             int x = current.Xindex;
             int y = current.Yindex;
             x = Math.Max(x - 1, 0);
             y = Math.Max(y - 1, 0);
             possibleCells = matrix.GetCellsByIndex(y, x, failedAttempts);
         }
         //go through each possible cell looking for those not already ignored.
         foreach (CellRange cr in possibleCells)
         {
             if (!ignoreCells.Contains(cr.CellNumber))
                 return cr.Copy();
         }
         return null;
     }
     current = matrix.GetCellByCpe(cpe1, cpe2);
     //then move appropriately
     if (Math.Abs(cpe1 - cpe2) >= Threshold)
     {
         if (cpe1 > cpe2)
         {
             //focus on CPE2
             int x = current.Xindex;
             int y = current.Yindex;
             x = Math.Max(x - 1, 0);
             return matrix.GetCellByIndex(y, x);
         }
         else
         {
             //focus on CPE1
             int x = current.Xindex;
             int y = current.Yindex;
             y = Math.Max(y - 1, 0);
             return matrix.GetCellByIndex(y, x);
         }
     }
     else
     { 
         //focus on both
         int x = current.Xindex;
         int y = current.Yindex;
         x = Math.Max(x - 1, 0);
         y = Math.Max(y - 1, 0);
         return matrix.GetCellByIndex(y, x);
     }
     return null;
 }