Exemplo n.º 1
0
        public Node(uint[] wave, ShapeGraph.Node node, uint entropy)
        {
            this.node    = node;
            this.wave    = wave;
            this.entropy = entropy;

            this.connections = new HashSet <Node>();
        }
Exemplo n.º 2
0
    private (ForwardCarry, HashSet <string>) Assign(ICollection <ControlAssignment> assignments, NodeMap nodePlacement)
    {
        ForwardCarry     forwardCarry      = new ForwardCarry();
        HashSet <string> activationSymbols = new HashSet <string>();
        HashSet <((uint, uint), string)> handledLocators = new HashSet <((uint, uint), string)>();

        // Console.WriteLine("Control");
        foreach (ControlAssignment ca in assignments)
        {
            // Get all the locators meant by the locator
            List <(uint, uint)> reqLocators = new List <(uint, uint)>();
            foreach ((uint x, uint y)all in nodePlacement.Keys)
            {
                if ((ca.Loc.x == all.x || ca.Loc.x == ~0u) && (ca.Loc.y == all.y || ca.Loc.y == ~0u))
                {
                    if (ca.Loc.x == all.x && ca.Loc.y == all.y)
                    {
                        reqLocators.Add(all);
                    }

                    else if (!handledLocators.Contains((all, ca.Attr)))
                    {
                        reqLocators.Add(all);
                    }

                    handledLocators.Add((all, ca.Attr));
                }
            }

            foreach ((uint x, uint y)all in reqLocators)
            {
                ShapeGraph.Node node = nodePlacement[all][0];

                // If the assignment is nonterminal, it will be used by
                // some following steps in the control pipeline
                if (!ca.IsTerminal)
                {
                    // If the assignment evokes WFC
                    if (this.activationSymbols.Contains(ca.Attr))
                    {
                        activationSymbols.Add(ca.Attr);
                    }

                    // If the assignment sets a WFC constraint
                    else
                    {
                        if (!forwardCarry.ContainsKey(node))
                        {
                            forwardCarry.Add(node, new HashSet <string>());
                        }

                        forwardCarry[node].Add(ca.Next);
                    }
                }

                else
                {
                    foreach (ShapeGraph.Node n in nodePlacement[all])
                    {
                        // Set the attribute
                        if (ca.Attr != "")
                        {
                            n.Shape.Attributes.Set(ca.Attr, new ScalarAttribute(ca.Value));
                        }

                        // Add the control symbol
                        if (ca.Next != "")
                        {
                            n.Shape.Control.Add(ca.Next);
                        }
                    }
                }
            }
        }

        return(forwardCarry, activationSymbols);
    }