Exemplo n.º 1
0
        public virtual Cell Reproduce(Coordinate anOffset)
        {
            Prey temp = new Prey(anOffset, _ocean);

            return(temp);
        }
Exemplo n.º 2
0
        private static void InitInhabitance(Ocean ocean, Images image)
        {
            int count;

            switch (image)
            {
            case Images.Obstacle:
                count = ocean.NumObstecles;
                break;

            case Images.Predators:
                count = ocean.NumPredators;
                break;

            case Images.Prey:
                count = ocean.NumPrey;
                break;

            default:
                count = 0;
                break;
            }

            for (int i = 0; i < count; i++)
            {
                bool res = false;

                do
                {
                    Coordinate coord = new Coordinate()
                    {
                        X = random.Next(0, ocean.NumCols),
                        Y = random.Next(0, ocean.NumRows)
                    };

                    res = ocean.IsBoundedCoordinate(coord) && ocean.IsEmptyCoordinate(coord);

                    if (res)
                    {
                        Cell newCell = null;

                        switch (image)
                        {
                        case Images.Obstacle:
                            newCell = new Obstacle(coord, ocean);
                            break;

                        case Images.Predators:
                            newCell = new Predator(coord, ocean);
                            break;

                        case Images.Prey:
                            newCell = new Prey(coord, ocean);
                            break;

                        default:
                            count = 0;
                            break;
                        }

                        ocean.AddCell(newCell);
                    }
                } while (!res);
            }
        }
Exemplo n.º 3
0
 public Prey(Prey source)
     : this(source._offset, source._ocean, source._initTimeToReproduce)
 {
 }