Example #1
0
        private PointData ConvertSolverField(SolverField field)
        {
            int x = field.X + DeskData.StartIndexX;
            int y = field.Y + DeskData.StartIndexY;

            return(new PointData()
            {
                X = x, Y = y
            });
        }
Example #2
0
        private int GetNeighboursValue(SolverField sf)
        {
            int distance   = 3;
            int totalValue = 0;

            int iMax = Array.Count;
            int jMax = Array[0].Count;


            for (int i = -distance; i <= distance; i++)
            {
                for (int j = -distance; j <= distance; j++)
                {
                    int iIndex = sf.Y + i;
                    int jIndex = sf.X + j;

                    if (iIndex < 0 || jIndex < 0 || iIndex >= iMax || jIndex >= jMax ||
                        (iIndex == sf.Y && jIndex == sf.X))
                    {
                        continue;
                    }
                    else
                    {
                        SolverField sfCheck = Array[iIndex][jIndex];
                        if (sfCheck.Type != EType.Empty)
                        {
                            if (sfCheck.Type == sf.Type)
                            {
                                totalValue += (5 * ((distance - Math.Abs(i) + (distance - Math.Abs(j)))));
                            }
                            else
                            {
                                totalValue += (((distance - Math.Abs(i)) + (distance - Math.Abs(j))));
                            }
                        }
                    }
                }
            }

            //for (int i = sf.Y - distance; i <= sf.Y + distance; i++)
            //{
            //  for(int j = sf.X - distance; j <= sf.X + distance; j++)
            //  {


            //  }
            //}

            return(totalValue);
        }
Example #3
0
        public PointData GetNextMove(DeskData deskData)
        {
            DeskData = deskData;
            Initialize();

            EvaluateFields(EType.Circle);
            EvaluateFields(EType.Cross);
            EvaluateFieldsValues(EType.Circle);

            //PrintValues();

            SolverField sfBest = GetBestField(EType.Circle);

            return(ConvertSolverField(sfBest));

            //SolverField sf = GetRandomField();
            //PointData pd = ConvertSolverField(sf);
            //return pd;
        }