Ejemplo n.º 1
0
        private int Run(int steps, LongPoint incX, LongPoint incY, LongPoint incZ, LongPoint incW)
        {
            IList <LongPoint4D> offsets = new List <LongPoint4D>();

            for (long x = incX.X; x <= incX.Y; x++)
            {
                for (long y = incY.X; y <= incY.Y; y++)
                {
                    for (long z = incZ.X; z <= incZ.Y; z++)
                    {
                        for (long w = incW.X; w <= incW.Y; w++)
                        {
                            LongPoint4D offset = new LongPoint4D(x, y, z, w);
                            if (LongPoint4D.Zero != offset)
                            {
                                offsets.Add(offset);
                            }
                        }
                    }
                }
            }

            // Initial data size
            LongPoint newX = new LongPoint(0, 7);
            LongPoint newY = new LongPoint(0, 7);
            LongPoint newZ = new LongPoint(0, 0);
            LongPoint newW = new LongPoint(0, 0);

            do
            {
                // Increment in each direction
                newX += incX;
                newY += incY;
                newZ += incZ;
                newW += incW;

                // Compute the new state
                Step(offsets, newX, newY, newZ, newW);
            }while (--steps > 0);

            return(_state.Values.Count(i => i.Previous == State.Active));
        }
Ejemplo n.º 2
0
        private void Step(IEnumerable <LongPoint4D> offsets, LongPoint newX, LongPoint newY, LongPoint newZ, LongPoint newW)
        {
            for (long x = newX.X; x <= newX.Y; x++)
            {
                for (long y = newY.X; y <= newY.Y; y++)
                {
                    for (long z = newZ.X; z <= newZ.Y; z++)
                    {
                        for (long w = newW.X; w <= newW.Y; w++)
                        {
                            Update(new LongPoint4D(x, y, z, w), offsets);
                        }
                    }
                }
            }

            foreach (Item item in _state.Values)
            {
                item.Reset();
            }
        }