コード例 #1
0
        public EcoSystemController(CanvasAnimatedControl control, MapSize mapSize, IEnumerable <Coordinates> obstacles)
        {
            this.control   = control;
            this.obstacles = obstacles;
            this.mapSize   = mapSize;

            generator      = new OpCodeGenerator();
            bots           = ImmutableList <BeetleBot> .Empty;
            map            = new CellType[mapSize.Width, mapSize.Height];
            cellSize       = new Size(control.Size.Width / mapSize.Width, control.Size.Height / mapSize.Height);
            genomeProducer = new GenomeProducer(generator, GenomeLength, 1);

            Epoch = 0;
            Scene = new Scene(this);

            control.PointerEntered  += OnPointerEntered;
            control.PointerExited   += OnPointerExited;
            control.PointerPressed  += OnPointerPressed;
            control.PointerReleased += OnPointerReleased;
            control.PointerMoved    += OnPointerMoved;
        }
コード例 #2
0
            public PositionProvider(IEnumerable <Coordinates> obstacles, MapSize mapSize)
            {
                random = new Random();
                free   = new List <Coordinates>();

                var occupied = new List <Coordinates>(obstacles);

                for (var y = 0; y < mapSize.Height; y++)
                {
                    for (var x = 0; x < mapSize.Width; x++)
                    {
                        var position = new Coordinates(x, y);

                        if (occupied.Contains(position))
                        {
                            continue;
                        }

                        free.Add(position);
                    }
                }
            }