Beispiel #1
0
        public void Any_live_cell_with_more_than_three_live_neighbours_dies()
        {
            var sut = new Game();

            var source = new bool[3, 3];

            source[1, 1] = true;
            source[0, 2] = true;
            source[2, 1] = true;
            source[2, 2] = true;
            source[1, 2] = true;

            source = sut.Play(source);

            Assert.AreEqual(false, source[1, 1]);
        }
Beispiel #2
0
        private Game CreateDescendants(int bestChromosomeNum, double crossoverProb)
        {
            while (true)
            {
                var boardA = _chromosomes[Random.Next(bestChromosomeNum)].Board;
                var boardB = _chromosomes[Random.Next(bestChromosomeNum)].Board;

                var boardChild = BoardFactory.Crossover(boardA, boardB, crossoverProb);

                var game = new Game(boardChild);
                game.Play(MaxIterationToPlay);

                if (game.Generation < MaxIterationToPlay) //the board didn't stabilize
                {
                    return(game);
                }
            }
        }
Beispiel #3
0
        public static Game Create(int rows, int columns, int minGenerationsAlive, double maxCoverage = 1)
        {
            //Console.WriteLine($"Start Create Game witch alive at minimum {minGenerationsAlive} generations");

            var random = new Random();

            while (true)
            {
                var coverage = random.NextDouble() * maxCoverage;
                var board    = BoardFactory.Create(rows, columns, coverage);
                var game     = new Game(board);
                game.Play(minGenerationsAlive);

                if (game.Generation >= minGenerationsAlive)
                {
                    return(game);
                }
            }
        }
 static void Main(string[] args)
 {
     Game game = new Game(1);
     game.Play();
 }
        static void Main(string[] args)
        {
            Game game = new Game(1);

            game.Play();
        }