Example #1
0
        public Labyrinth(int width, int height, int targetX, int targetY, int startValue = 2)
        {
            Width  = width;
            Height = height;

            Target = new SquareTarget(new Block(targetX, targetY));

            H = new RelationArray(width - 1, height, startValue);
            V = new RelationArray(width, height - 1, startValue);
        }
Example #2
0
        private IEnumerable <string> GetClosedRealtions(RelationArray array)
        {
            IRelationInterpreter interpreter = new ActualInterpreter();

            for (int i = 0; i < array.Width; i++)
            {
                for (int j = 0; j < array.Height; j++)
                {
                    if (!interpreter.IsOpen(array[i, j]))
                    {
                        yield return(i + "x" + j);
                    }
                }
            }
        }
Example #3
0
        private void GetRelation(double x, double y, out RelationArray array, out int i, out int j)
        {
            double hX = Math.Round(x);
            double hY = y - y % 1 + 0.5;
            double vX = x - x % 1 + 0.5;
            double vY = Math.Round(y);

            if (Distance(x, y, hX, hY) < Distance(x, y, vX, vY))
            {
                array = V;
                i     = (int)hX;
                j     = (int)(hY - 0.5);

                if (i >= Width)
                {
                    i = Width - 1;
                }
                if (j + 1 >= Height)
                {
                    i = Height - 2;
                }
            }
            else
            {
                array = H;
                i     = (int)(vX - 0.5);
                j     = (int)vY;

                if (i + 1 >= Width)
                {
                    i = Width - 2;
                }
                if (j >= Height)
                {
                    i = Height - 1;
                }
            }

            if (i < 0)
            {
                i = 0;
            }
            if (j < 0)
            {
                j = 0;
            }
        }