Example #1
0
        public static bool IsKierstead(Knowledge knowledge, Board board, int edgeIndex, List <int> ordering)
        {
            var gn = knowledge.GraphKnowledge;

            return(gn.LineGraph.IsChoosable(Enumerable.Range(0, gn.LineGraph.N).Select(e =>
            {
                if (e == edgeIndex)
                {
                    return -1;
                }

                var edge = gn.Edges[e];
                var j = Math.Max(ordering.IndexOf(edge.Item1), ordering.IndexOf(edge.Item2));
                var priorStacks = board.Stacks.Where((stack, i) => ordering.IndexOf(i) < j).ToList();

                long allowedList = 0;
                var list = knowledge.GetEdgeColorList(board, e);
                foreach (var alpha in list.EnumerateBits())
                {
                    if (MetaKnowledge.d_H(alpha, priorStacks) % 2 == 0)
                    {
                        allowedList = allowedList.SetBit(alpha);
                    }
                }

                return allowedList;
            }).ToList()));
        }
Example #2
0
        public static bool ColorableWithoutEdge(Knowledge knowledge, List <long> stacks, int edgeIndex)
        {
            var lg = knowledge.GraphKnowledge.LineGraph;

            return(lg.IsChoosable(Enumerable.Range(0, lg.N).Select(e =>
            {
                if (e == edgeIndex)
                {
                    return -1;
                }

                return knowledge.GetEdgeColorList(stacks, e);
            }).ToList()));
        }
Example #3
0
        public bool Analyze(Knowledge knowledge, Board board)
        {
            var lineGraph = knowledge.GraphKnowledge.LineGraph;
            var canColor  = lineGraph.IsChoosable(Enumerable.Range(0, lineGraph.N).Select(e => knowledge.GetEdgeColorList(board, e)).ToList());

            if (canColor)
            {
                knowledge[board.Template.Value][board.ColorCount].AddWin(board, Reason);
            }

            return(canColor);
        }