Example #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
                }
            }
        }
Example #2
0
        public void Step(int numberOfSteps) //TODO Move into FloorTile and use events!
        {
            for (int step_count = 0; step_count < numberOfSteps; step_count++)
            {
                int home_score = GetHomeSquareValue();
                //TODO - here decrement any decrementable tiles
                for (int x_count = 0; x_count < _board.GetLength(0); x_count++)
                {
                    for (int y_count = 0; y_count < _board.GetLength(1); y_count++)
                    {
                        FloorTile current_tile = _board[x_count, y_count];
                        switch (current_tile.GetTileType())
                        {
                        case (FloorTile.TileType.Pheremone):
                        {
                            if (!_board[x_count, y_count].ModifyValue())
                            {
                                _board[x_count, y_count] = new FloorTile(_control, FloorTile.TileType.Blank);
                            }
                            break;
                        }

                        default:
                        {
                            break;
                        }
                        }
                    }
                }
            }
        }
Example #3
0
        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;
        }
Example #4
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);
            }
        }