Ejemplo n.º 1
0
            static bool IsStateWon(State s, Action lastAction)
            {
                var winSize = lastAction.Agent == 1 ? A : B;
                var edge    = LookupEdge(N, lastAction.E);
                var n1      = s.GetNeighborsOfColor(edge.Item1, lastAction.Agent);
                var n2      = s.GetNeighborsOfColor(edge.Item2, lastAction.Agent);
                var common  = ListUtility <int> .Intersection(n1, n2);

                return(s.IsCliqueOfSize(common, winSize - 2, lastAction.Agent));
            }
Ejemplo n.º 2
0
            bool IsCliqueOfSize(List <int> vertices, int size, int color)
            {
                if (vertices.Count < size)
                {
                    return(false);
                }
                if (size <= 1)
                {
                    return(true);
                }

                for (int i = 0; i < vertices.Count; i++)
                {
                    var neighbors = ListUtility <int> .Intersection(vertices.Skip(i + 1), GetNeighborsOfColor(vertices[i], color));

                    if (IsCliqueOfSize(neighbors, size - 1, color))
                    {
                        return(true);
                    }
                }

                return(false);
            }