コード例 #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);
        }
コード例 #2
0
 public RDList SurroundingOf(RDCell cell, object factPool)
 {
     return(new RDList(new RDElement[] {
         new RDCell(cell.X - 1, cell.Y - 1),
         new RDCell(cell.X - 1, cell.Y),
         new RDCell(cell.X - 1, cell.Y + 1),
         new RDCell(cell.X, cell.Y - 1),
         new RDCell(cell.X, cell.Y),
         new RDCell(cell.X, cell.Y + 1),
         new RDCell(cell.X + 1, cell.Y - 1),
         new RDCell(cell.X + 1, cell.Y),
         new RDCell(cell.X + 1, cell.Y + 1)
     }));
 }
コード例 #3
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);
        }
コード例 #4
0
        public RDNumber ColorOf(RDCell cell, object factPool)
        {
            FactPool pool = (FactPool)factPool;

            return(new RDNumber(pool.Result[cell.X, cell.Y]));
        }
コード例 #5
0
 public RDNumber NumberOf(RDCell cell, object factPool)
 {
     return(new RDNumber(((FactPool)factPool).Cell[cell.X, cell.Y]));
 }