Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            // TODO: Add your initialization logic here


            position = new Vector2(0, 0);

            int    Width  = 100;
            int    Height = 40;
            byte   Rule   = 90;
            double percentInitiallyActive = 0.5;

            //int NumSeeds = Convert.ToInt32(Width * Height * percentInitiallyActive);

            List <Coords> seeds = RandomCoordGenerator.GetCoords(Width, Height, percentInitiallyActive);

            //List<Coords> seeds = new List<Coords>{ new Coords(Width / 2, 0) };

            World = new WolframWorld(Width, Height, Rule, seeds);



            //graphics.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width;
            //graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
            //graphics.IsFullScreen = true;

            graphics.PreferredBackBufferWidth  = 1600;
            graphics.PreferredBackBufferHeight = 800;
            graphics.ApplyChanges();
        }
Exemplo n.º 2
0
        private Ship GenerateValidShipOfLength(int length, RandomCoordGenerator random)
        {
            Ship ship;

            do
            {
                // Prevent if overlap
                ship = GenerateShipOfLength(length, random);
            }while (ShipOverlaps(ship));
            return(ship);
        }
Exemplo n.º 3
0
        public SetupBoard GenerateRandom()
        {
            if (m_ShipsByLength.Values.Any(ss => ss.Count > 0))
            {
                throw new InvalidOperationException("Ships have already been added manually.");
            }

            var coordGen = new RandomCoordGenerator();

            foreach (var req in s_LengthShipsRequired)
            {
                for (int i = 1; i <= req.Value; i++)
                {
                    var ship = GenerateValidShipOfLength(req.Key, coordGen);
                    RecordShip(ship);
                }
            }

            return(this);
        }
Exemplo n.º 4
0
 private static Ship GenerateShipOfLength(int length, RandomCoordGenerator random)
 {
     var(start, end) = random.GetRandomShipCoords(length);
     return(new Ship(start, end));
 }