コード例 #1
0
        public GameBoard(ControlClass control, Random random, int width, int height, Rectangle homeSquareRect)
        {
            _control = control;
            _random  = random;

            _board = new FloorTile[width, height];
            _pheremone_locations = new List <Pheremone> [width, height];
            _homeSquare          = homeSquareRect;

            for (int width_count = 0; width_count < width; width_count++)
            {
                for (int height_count = 0; height_count < height; height_count++)
                {
                    _board[width_count, height_count] = new FloorTile(_control, FloorTile.TileType.Blank);
                    _pheremone_locations[width_count, height_count] = new List <Pheremone>();
                }
            }

            for (int home_square_width_count = 0; home_square_width_count < homeSquareRect.Width; home_square_width_count++)
            {
                for (int home_square_height_count = 0; home_square_height_count < homeSquareRect.Height; home_square_height_count++)
                {
                    _board[home_square_width_count + homeSquareRect.X, home_square_height_count + homeSquareRect.Y] = new FloorTile(_control, FloorTile.TileType.Home, 10); //TODO remove magic number
                }
            }
        }
コード例 #2
0
        public Form1()
        {
            InitializeComponent();

            _control = new ControlClass(_numberOfNormalAnts); //TODO get from correct bit of UI

            _control.BoardStepped += _control_BoardStepped;
        }
コード例 #3
0
        public GameBoard(ControlClass control, Random random, int width, int height, Rectangle homeSquareRect, Point[] goalLocations) : this(control, random, width, height, homeSquareRect)
        {
            _goals = goalLocations;

            foreach (Point goal_location in goalLocations)
            {
                _board[goal_location.X, goal_location.Y] = new FloorTile(_control, FloorTile.TileType.Goal, value: _random.Next(_maxGoalScore, _maxGoalScore));
            }
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            GenerateNewBoard new_board = new GenerateNewBoard(this);

            new_board.ShowDialog();
            _control = new ControlClass(_numberOfNormalAnts, _boardWidth, _boardHeight, _goalTiles);//TODO is this correct?

            _control.BoardStepped += _control_BoardStepped;
            //TODO draw the board?
        }
コード例 #5
0
ファイル: FloorTile.cs プロジェクト: beno11224/Ant_Simulation
        public FloorTile(ControlClass control, TileType tileType, int value) : this(control, tileType) //the "this:" at the end runs the above constructor too
        {
            _value = value;
            if (tileType == TileType.Pheremone)
            {
                if (value > 255)
                {
                    throw new ArgumentException("Value of a pheremone cannot be greater than 255");
                }

                _colour = Color.FromArgb(100, 100, value);
            }
        }
コード例 #6
0
ファイル: Ant.cs プロジェクト: beno11224/Ant_Simulation
        public Pheremone(ControlClass control, Point location, int initialValue, double decayRate)
        {
            if (initialValue > 255)
            {
                throw new ArgumentException("intialValue cannot be greater than 255");
            }
            _initial_value = initialValue;
            _current_value = initialValue;
            _location      = location;
            _tile          = new FloorTile(control, FloorTile.TileType.Special, initialValue, initialValue);
            _decayRate     = decayRate;
            _parent        = control;

            _parent.BoardStepped += parent_BoardStepped;
        }
コード例 #7
0
ファイル: FloorTile.cs プロジェクト: beno11224/Ant_Simulation
        public FloorTile(ControlClass control, TileType tileType)
        {
            _control = control;

            //_control.BoardStepped += Decay(); //TODO

            _tileType = tileType;
            _value    = 0;

            switch (tileType)
            {
            case (TileType.Blank):
            {
                _colour = Color.LightSlateGray;
                break;
            }

            case (TileType.Goal):
            {
                _colour = Color.Yellow;
                break;
            }

            case (TileType.Home):
            {
                _colour = Color.Green;
                break;
            }

            case (TileType.Special):
            {
                _colour = Color.Orange;         //TODO will this work??
                break;
            }

            case (TileType.Pheremone):
            {
                _colour = Color.Blue;
                break;
            }
            }
        }
コード例 #8
0
        public GameBoard(ControlClass control, Random random, int width, int height, Rectangle homeSquareRect, int numberOfGoalLocations) : this(control, random, width, height, homeSquareRect)
        {
            _goals = new Point[numberOfGoalLocations];

            for (int goal_count = 0; goal_count < numberOfGoalLocations; goal_count++)
            {
                int board_x;
                int board_y;
                do
                {
                    board_x = _random.Next(width);
                    board_y = _random.Next(height);
                }while (board_x > _homeSquare.X &&
                        board_x < (_homeSquare.X + _homeSquare.Width) &&
                        board_y > _homeSquare.Y &&
                        board_y < (_homeSquare.Y + _homeSquare.Width));
                //While loop stops goals spawning in home_square

                _board[board_x, board_y] = new FloorTile(_control, FloorTile.TileType.Goal, value: _random.Next(_minGoalScore, _maxGoalScore));

                _goals[goal_count] = new Point(board_x, board_y);
            }
        }
コード例 #9
0
ファイル: FloorTile.cs プロジェクト: beno11224/Ant_Simulation
 public FloorTile(ControlClass control, TileType tileType, int value, double modifier) : this(control, tileType, value)
 {
     _modifer = modifier;
 }
コード例 #10
0
ファイル: FloorTile.cs プロジェクト: beno11224/Ant_Simulation
 public FloorTile(ControlClass control, TileType tileType, int value, int maxValue) : this(control, tileType, value) //the "this:" at the end runs the above constructor too
 {
     _maxValue = maxValue;
 }