Exemple #1
0
 /// <summary>
 /// Creates a new waldo with the specified (x,y) coordinate and starting direction.
 /// </summary>
 /// <param name="start">the start information for the waldo</param>
 /// <param name="bound">the rectangular grid the waldo is confined to</param>
 public Waldo(StartInstruction start, Rectangle bound, WaldoType type)
 {
     this.x                = start.x;
     this.y                = start.y;
     this.bound            = bound;
     this.Type             = type;
     this.CurrentDirection = start.direction;
     this.Atom             = null;
 }
        private Reactor(Parse.Reactor reactor)
        {
            int width  = reactor.width;
            int height = reactor.height;

            Width  = width;
            Height = height;

            inZoneAlpha  = new Rectangle(0, 0, 4, 4);
            outZoneAlpha = new Rectangle(6, 0, 4, 4);
            inZoneBeta   = new Rectangle(0, 4, 4, 4);
            outZoneBeta  = new Rectangle(6, 4, 4, 4);

            tiles = new Tile[width, height];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    var zone = ClassifyAsZone(new Point(i, j));
                    tiles[i, j] = new Tile(i, j, zone);
                }
            }

            foreach (Parse.Tile tile in reactor.tiles)
            {
                tiles[tile.x, tile.y].Set(tile);
            }

            AlphaStart = new StartInstruction(reactor.starts.alpha);
            BetaStart  = new StartInstruction(reactor.starts.beta);

            AlphaInput = new InputFactory(reactor.inputs.alpha);
            BetaInput  = new InputFactory(reactor.inputs.beta);

            if (reactor.outputs.IsAlphaOutput)
            {
                AlphaOutput = new Output(reactor.outputs.alpha);
            }

            if (reactor.outputs.IsBetaOutput)
            {
                BetaOutput = new Output(reactor.outputs.beta);
            }
        }