Beispiel #1
0
 /// <summary>
 ///     Returns how close the city is to another city.
 /// </summary>
 /// <param name="cother">The other city.</param>
 /// <returns>A distance.</returns>
 public int Proximity(City cother)
 {
     return Proximity(cother.X, cother.Y);
 }
Beispiel #2
0
        /// <summary>
        ///     Place the cities in random locations.
        /// </summary>
        private void InitCities()
        {
            IGenerateRandom rnd = new MersenneTwisterGenerateRandom();
            _cities = new City[Cities];
            for (int i = 0; i < _cities.Length; i++)
            {
                int xPos = rnd.NextInt(MapSize);
                int yPos = rnd.NextInt(MapSize);

                _cities[i] = new City(xPos, yPos);
            }
        }
        /// <summary>
        ///     Place the cities in random locations.
        /// </summary>
        /// <param name="rnd">Random number.</param>
        private void InitCities(IGenerateRandom rnd)
        {
            _cities = new City[Cities];
            for (int i = 0; i < _cities.Length; i++)
            {
                int xPos = rnd.NextInt(0, MapSize);
                int yPos = rnd.NextInt(0, MapSize);

                _cities[i] = new City(xPos, yPos);
            }
        }
Beispiel #4
0
 /// <summary>
 ///     The constructor.
 /// </summary>
 /// <param name="cities">The cities.</param>
 public TSPScore(City[] cities)
 {
     _cities = cities;
 }