Ejemplo n.º 1
0
        private void SetUp()
        {
            var previous = Guid.NewGuid();

            for (var i = 0; i < binaryValue.Length; i++)
            {
                var value = binaryValue[i];
                var bit   = value == '0' ? (AbstractBit) new ZeroBit(binaryValue, i, Modes.Copy, signal) : new OneBit(binaryValue, i, Modes.Copy, signal);


                // the first tile needs to bind with the hook, according to this binary string's data
                bit.NorthGlue = i == 0 ? startGlue : new Glue(previous.ToString());


                // the last tiles should propagate a copy stopper, every other bit should propagate another bit
                previous = Guid.NewGuid();

                var lastBit = i + 1 == binaryValue.Length;

                if (lastBit)
                {
                    var valueBase10 = Convert.ToInt32(binaryValue, 2) + 1;
                    bit.SouthGlue = valueBase10 <= stoppingValue?GlueFactory.CopyStopper(signal) : new Glue();
                }
                else
                {
                    bit.SouthGlue = new Glue(previous.ToString());
                }

                List <Tile> results = bit.Tiles().ToList();
                if (value == '1')
                {
                    foreach (var tile in results)
                    {
                        tile.Color = "blue";
                    }
                }

                tiles.AddRange(results);
            }
        }
Ejemplo n.º 2
0
        private void SetUp()
        {
            topRight    = Tile(TileNames.CopyStopperTopRight);
            topLeft     = Tile(TileNames.CopyStopperTopLeft);
            bottomLeft  = Tile(TileNames.CopyStopperBottomLeft);
            bottomRight = Tile(TileNames.CopyStopperBottomRight);

            topRight.North = GlueFactory.CopyStopper(signal);

            topRight.West = Bind(topRight, topLeft);
            topLeft.East  = topRight.West;

            topLeft.South    = Bind(topLeft, bottomLeft);
            bottomLeft.North = topLeft.South;

            bottomLeft.East  = Bind(bottomLeft, bottomRight);
            bottomRight.West = bottomLeft.East;

            bottomRight.South = GlueFactory.PreReadRight(signal);
            tiles             = new List <Tile> {
                topRight, topLeft, bottomLeft, bottomRight
            };
        }