Esempio n. 1
0
        public void DiagonalNumberPair(string name1, string name2, Dictionary <string, RDElement> dict, object factPool, Rule rule, Action <int> callBack, int callBackID)
        {
            FactPool pool = (FactPool)factPool;

            for (int x = 1; x <= pool.X; ++x)
            {
                for (int y = 1; y <= pool.Y; ++y)
                {
                    if (IsUnfinishedNumberCell(x, y, factPool) && IsUnfinishedNumberCell(x + 1, y + 1, factPool))
                    {
                        dict[name1] = new RDCell(x, y);
                        dict[name2] = new RDCell(x + 1, y + 1);
                        callBack.Invoke(callBackID);
                        dict[name1] = new RDCell(x + 1, y + 1);
                        dict[name2] = new RDCell(x, y);
                        callBack.Invoke(callBackID);
                    }
                    if (IsUnfinishedNumberCell(x, y + 1, factPool) && IsUnfinishedNumberCell(x + 1, y, factPool))
                    {
                        dict[name1] = new RDCell(x, y + 1);
                        dict[name2] = new RDCell(x + 1, y);
                        callBack.Invoke(callBackID);
                        dict[name1] = new RDCell(x + 1, y);
                        dict[name2] = new RDCell(x, y + 1);
                        callBack.Invoke(callBackID);
                    }
                }
            }
            dict.Remove(name1);
            dict.Remove(name2);
        }
Esempio n. 2
0
        public bool ColorOf(RDCell cell, RDNumber result, object factPool)
        {
            //Console.WriteLine(edge.X + "::" + edge.Y);
            FactPool pool = (FactPool)factPool;

            if (pool.Result[cell.X, cell.Y] != 0)
            {
                if (pool.Result[cell.X, cell.Y] != result.Data)
                {
                    throw new Exception("结果冲突!");
                }
                return(false);
            }
            pool.Result[cell.X, cell.Y] = result.Data;
            return(true);
        }
Esempio n. 3
0
        private bool IsUnfinishedNumberCell(int x, int y, object factPool)
        {
            FactPool pool = (FactPool)factPool;

            if (pool.Cell[x, y] == -1)
            {
                return(false);
            }
            for (int i = x - 1; i <= x + 1; ++i)
            {
                for (int j = y - 1; j <= y + 1; ++j)
                {
                    if (pool.Result[i, j] == 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 4
0
        public RDNumber ColorOf(RDCell cell, object factPool)
        {
            FactPool pool = (FactPool)factPool;

            return(new RDNumber(pool.Result[cell.X, cell.Y]));
        }