Ejemplo n.º 1
0
        public void Clear()
        {
            toPropagate.Clear();

            compatible = new int[indexCount, patternCount, directionsCount];
            for (int index = 0; index < indexCount; index++)
            {
                if (!topology.ContainsIndex(index))
                {
                    continue;
                }

                for (int pattern = 0; pattern < patternCount; pattern++)
                {
                    for (int d = 0; d < directionsCount; d++)
                    {
                        if (topology.TryMove(index, (Direction)d, out var dest, out var _, out var el))
                        {
                            var compatiblePatterns = propagatorArray[pattern][(int)el].Length;
                            compatible[index, pattern, d] = compatiblePatterns;
                            if (compatiblePatterns == 0 && propagator.Wave.Get(index, pattern))
                            {
                                if (propagator.InternalBan(index, pattern))
                                {
                                    propagator.SetContradiction();
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
        public void Propagate()
        {
            while (toPropagate.Count > 0)
            {
                var item    = toPropagate.Pop();
                var index   = item.Index;
                var pattern = item.Pattern;


                int x, y, z;
                topology.GetCoord(index, out x, out y, out z);
                for (var d = 0; d < directionsCount; d++)
                {
                    if (!topology.TryMove(x, y, z, (Direction)d, out var i2, out Direction id, out EdgeLabel el))
                    {
                        continue;
                    }
                    var patternsDense = propagatorArrayDense[pattern][(int)el];

                    for (var p = 0; p < patternCount; p++)
                    {
                        if (patternsDense[p])
                        {
                            continue;
                        }

                        if (wave.Get(i2, p))
                        {
                            if (propagator.InternalBan(i2, p))
                            {
                                propagator.SetContradiction();
                            }
                        }
                    }
                }
            }
        }