Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            int maxX            = 50;
            int maxY            = 10;
            var eventAggregator = new EventAggregator();
            var cellFactory     = new DefaultCellFactory();

            var germFactory = new InfectiousGermFactory(eventAggregator);
            var tissueMap   = new Tissue2DFactory(cellFactory, germFactory, new FisherYatesShuffle())
                              .Create(maxX, maxY, 0.7f, 0.05f);
            var cellStringEncoder = new CellStringEncoder();
            var roundBasedGame    = new RoundBasedGame(new TissueGrowthMechanism(), new RandomInfectionPropagation(germFactory, eventAggregator),
                                                       eventAggregator, false);

            var rounds = new List <TissuePrinter>();

            for (int i = 0; i < 50; i++)
            {
                var printer = new TissuePrinter(tissueMap, cellStringEncoder);
                rounds.Add(printer);
                tissueMap = roundBasedGame.Advance(tissueMap);
            }

            foreach (var round in rounds)
            {
                Console.Clear();
                round.PrintTissue();
                Thread.Sleep(500);
            }

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public void Create_Tissue2D_WithCorrectLocationOrigin(int x, int y,
                                                              [FloatAsRatio] float living,
                                                              [Frozen(Matching.ImplementedInterfaces)]
                                                              ReverseTestShuffler shuffler, //we need to make sure max Location is in but do not want to use a complex shuffler
                                                              Tissue2DFactory sut)
        {
            Tissue2D result = sut.Create(x, y, living, 1 - living);

            VerifyLocationBounds(x, y, result);
        }
Ejemplo n.º 3
0
        public void Create_Tissue2D_WithCorrectNumberOfCells(int x, int y,
                                                             [FloatAsRatio] float living,
                                                             [Frozen(Matching.ImplementedInterfaces)]
                                                             NullShuffle shuffler,
                                                             Tissue2DFactory sut)
        {
            Tissue2D result = sut.Create(x, y, living, 1 - living);

            result.Tissue.Count.Should().Be(x * y);
        }
Ejemplo n.º 4
0
        public void Create_Tissue2D_AllPositionsAreCreated(
            [MinMaxInt(0, 50)] int x,
            [MinMaxInt(0, 50)] int y,
            [FloatAsRatio] float variableRatio,
            [Frozen(Matching.ImplementedInterfaces)]
            NullShuffle shuffler, //do not shuffle but inject when generating sut
            Tissue2DFactory sut)
        {
            var infected = variableRatio;
            var healthy  = 1 - variableRatio;

            var result = sut.Create(x, y, healthy, infected);

            VerifyAllLocationAreCreated(x, y, result);
        }
Ejemplo n.º 5
0
        public void Create_Tissue2D_CorrectCellsRatiosAreCreated(int x, int y,
                                                                 [FloatAsRatio] float variableRatio,
                                                                 [Frozen(Matching.ImplementedInterfaces)]
                                                                 NullShuffle shuffler, //do not shuffle but inject when generating sut
                                                                 [Frozen] ICellFactory cellFactory,
                                                                 Tissue2DFactory sut)
        {
            var infected = variableRatio;
            var healthy  = 1 - variableRatio;

            (int expectedHealthyCells, int expectedInfectedCells, int expectedEmptyPlaces)
                = CalculateExpectations(x, y, healthy, infected);

            _ = sut.Create(x, y, healthy, infected);

            var cellFactoryMock = Mock.Get(cellFactory);

            VerifyCorrectCellCounts(cellFactoryMock, expectedHealthyCells, expectedInfectedCells, expectedEmptyPlaces);
        }