예제 #1
0
 public static void print(this RuleData self, int nPatterns)
 {
     for (int from = 0; from < self.nPatterns; from++)
     {
         for (int to = from; to < self.nPatterns; to++)
         {
             for (int d = 0; d < 4; d++)
             {
                 if (!self.isLegal(new PatternId(from), (Dir4)d, new PatternId(to)))
                 {
                     continue;
                 }
                 Console.WriteLine($"legal: {from} to {to} in {(Dir4) d}");
             }
         }
     }
 }
예제 #2
0
        public State(int width, int height, PatternStorage patterns, ref RuleData rule)
        {
            int nPatterns = patterns.len;

            this.gridSize = new Vec2i(width, height);

            this.possibilities = new Grid3D <bool>(width, height, nPatterns);
            this.enablerCounts = EnablerCounter.initial(width, height, patterns, ref rule);
            this.entropies     = new Grid2D <EntropyCacheForCell>(width, height);

            var initialEntropyCache = EntropyCacheForCell.initial(patterns);

            for (int i = 0; i < width * height; i++)
            {
                this.entropies.add(initialEntropyCache);
                for (int j = 0; j < nPatterns; j++)
                {
                    this.possibilities.add(true);
                }
            }
        }