예제 #1
0
        public void RunDemo(int tabIndex)
        {
            SimulationEnvironment sim = new SimulationEnvironment();

            // Add Test Nodes
            sim.AddNode(new MobileNode(100, 100, 20));
            sim.AddNode(new MobileNode(200, 210, 20));
            sim.AddNode(new MobileNode(210, 200, 100));
            sim.AddNode(new MobileNode(298, 298, 100));
            // Add Test Message
            sim.AddMessage(new Message(sim.GetNodes()[0], sim.GetNodes()[3]));
            // Print Simulation Nodes
            new OutputPaneController().PrintToOutputPane("Note", "Simulation Nodes:");
            foreach (MobileNode node in sim.GetNodes())
            {
                node.Print();
                node.PrintNodesWithinRange(sim);
            }
            // Testing DSR

            /*new OutputPaneController().PopulateNodesDSR(sim.GetNodes(), tabIndex);
             * sim.SendMessageDSR(sim.GetMessages()[0]);*/
            // Testing SADSR

            /*new OutputPaneController().PopulateNodesSADSR(sim.GetNodes(), tabIndex);
             * sim.SendMessageSADSR(sim.GetMessages()[0]);*/
            // Testing modified SADSR
            new OutputPaneController().PopulateNodesMSADSR(sim.GetNodes(), tabIndex);
            sim.SendMessageMSADSR(sim.GetMessages()[0]);
        }
        public void Should_Remove_A_Door_From_The_List_That_The_User_Didnt_Select()
        {
            // Arrange
            var doors = new List <IDoor>
            {
                new Door()
                {
                    ContainsPrize = false, IsUsersSelection = true
                },
                new Door()
                {
                    ContainsPrize = true, IsUsersSelection = true
                },
                new Door()
                {
                    ContainsPrize = false
                },
            };

            var gameshow = new SimulationEnvironment(doors);

            // Act
            gameshow.EliminateAClosedDoor();
            var numberOfDoors = gameshow.Doors.Count();
            var removedTheNonUserSelectedDoor = gameshow.Doors.All(d => d.IsUsersSelection);

            // Assert
            Assert.Equal(2, numberOfDoors);
            Assert.True(removedTheNonUserSelectedDoor);
        }
 public GenericCellGrower(IPlant plant, SimulationEnvironment environment, ICellBodySystemSolver systemSolver, IPlantSimulatorOptionsService optionsService)
 {
     this.plant          = plant;
     this.environment    = environment;
     this.systemSolver   = systemSolver;
     this.optionsService = optionsService;
 }
        public void Should_Place_A_Prize_Behind_A_Door()
        {
            // Arrange
            var doors = new List <IDoor>
            {
                new Door()
                {
                    ContainsPrize = false
                },
                new Door()
                {
                    ContainsPrize = false
                },
                new Door()
                {
                    ContainsPrize = false
                }
            };

            var gameshow = new SimulationEnvironment(doors);

            //Act
            gameshow.PlacePrizeBehindRandomDoor();
            var result = gameshow.Doors.Count(d => d.ContainsPrize);

            //Assert
            Assert.Equal(1, result);
        }
        public void Should_Simulate_A_User_Selecting_A_Random_Door()
        {
            // Arrange
            var doors = new List <IDoor>
            {
                new Door()
                {
                    ContainsPrize = false
                },
                new Door()
                {
                    ContainsPrize = false
                },
                new Door()
                {
                    ContainsPrize = false
                },
            };

            var gameshow = new SimulationEnvironment(doors);

            //Act
            gameshow.ChooseARandomDoorForTheUser();
            var result = gameshow.Doors.Count(d => d.IsUsersSelection);

            //Assert
            Assert.Equal(1, result);
        }
예제 #6
0
 public override IEnumerable <Event> Execute(SimulationEnvironment environment)
 {
     while (true)
     {
         yield return(environment.Timeout(_tick));
     }
 }
 public GenericPlantRunner(IPlant plant, SimulationEnvironment environment, IPlantGrower plantGrower, FluidsPlantCycle sucroseCycle)
 {
     this.plantGrower  = plantGrower;
     this.sucroseCycle = sucroseCycle;
     Plant             = plant;
     Environment       = environment;
 }
 public void Setup()
 {
     environment = new SimulationEnvironment {
         LightPosition = new Vertex(0, 10000, 0), Temperature = 22
     };
     plant                         = TestPlant.CreatePlant();
     cellFactory                   = new GenericCellFactory();
     optionsService                = PlantSimulatorOptionsHelper.CreateOptionsService();
     divider                       = new GenericCellDivider(cellFactory);
     helper                        = new GeometryHelper();
     cellSizer                     = new GenericCellSizer(helper, new LoggerAdapter <GenericCellSizer>(new NullLogger <GenericCellSizer>()));
     cellCollisionDetection        = new CellCollisionDetection(helper);
     bodySystemSolver              = new GenericCellBodySystemSolver(cellCollisionDetection, cellSizer);
     cellGrower                    = new GenericCellGrower(plant, environment, bodySystemSolver, optionsService);
     descriptorService             = new PlantDescriptorService();
     cellCreator                   = new HexagonCellCreator(cellFactory);
     gridCreator                   = new HexagonalCellGridFactory(cellCreator, CornCellTypeLocator.GetCornCellTypeLocator(), optionsService);
     plantPartCellCreator          = new PlantPartCellCreator(gridCreator);
     internodePartFactory          = new GenericInternodePartFactory(optionsService, gridCreator);
     stemPartFactory               = new GenericStemPartFactory(optionsService, internodePartFactory);
     petiolePartFactory            = new GenericPetiolePartFactory(cellFactory, optionsService);
     nodePartFactory               = new GenericNodePartFactory(optionsService, cellFactory, stemPartFactory, petiolePartFactory);
     internodePlantPartDevelopment = new InternodePartDevelopment(optionsService, nodePartFactory, cellGrower, descriptorService, internodePartFactory);
     rootFactory                   = new GenericRootPartFactory(optionsService, plantPartCellCreator);
     rootPlantPartDevelopment      = new RootPartDevelopment(optionsService, nodePartFactory, rootFactory, cellGrower, descriptorService);
     developer                     = new PlantPartDeveloper(internodePlantPartDevelopment, rootPlantPartDevelopment);
     sucroseCarrierCollection      =
         new SucroseCarrierCollection(
             new LoggerAdapter <SucroseCarrierCollection>(new NullLogger <SucroseCarrierCollection>()));
     sucroseTransporter     = new SucroseTransporter(cellCollisionDetection, helper, sucroseCarrierCollection, new LoggerAdapter <FluidTransporter <Sucrose> >(new NullLogger <FluidTransporter <Sucrose> >()));
     plantGrower            = new GenericPlantGrower(bodySystemSolver, developer, sucroseTransporter);
     runner                 = new GenericPlantRunner(plant, environment, plantGrower, new FluidsPlantCycle(plant, optionsService, sucroseCarrierCollection, new LoggerAdapter <FluidsPlantCycle>(new NullLogger <FluidsPlantCycle>())));
     RangeExtensions.Random = new Random(optionsService.Options.Simulation.RandomSeed);
 }
예제 #9
0
 public override IEnumerable <Event> Execute(SimulationEnvironment environment)
 {
     while (true)
     {
         Console.WriteLine(environment.Now);
         yield return(environment.Timeout(TimeSpan.FromSeconds(1)));
     }
 }
예제 #10
0
        public void RunTest(
            int nodeNumber,
            int messageNumber,
            int simSpeedNumber,
            int tabIndex)
        {
            SimulationEnvironment sim = new SimulationEnvironment();

            sim.GenerateRandomNodes(nodeNumber);
            sim.GenerateRandomMessages(messageNumber);
            new OutputPaneController().PopulateNodesDSR(sim.GetNodes(), tabIndex);
            sim.RunSimulation();
        }
예제 #11
0
        public static void Main(string[] args)
        {
            ArgumentParser ap = new ArgumentParser(args);

            Environment.CurrentDirectory = ap.ConfigPath;
            SimulationEnvironment simEnv = new SimulationEnvironment(
                ap.ConfigFileName,
                new ModuleFactory(),
                new CommnadLineInterface(ap.SilentMode));

            simEnv.Init();

            simEnv.Run();
        }
        public void TestAddGetModules()
        {
            SimulationEnvironment simEnv = new SimulationEnvironment("", null, null);

            simEnv.AddModule(new MockModule("m", 2));
            simEnv.AddModule(new MockModule("m", 2)); //Index 1

            Module a = simEnv.GetModule("m", 0);

            Assert.NotNull(a);
            Module b = simEnv.GetModule("m", 1);

            Assert.NotNull(b);
        }
예제 #13
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainScreen            mainScreen              = new MainScreen();
            TargetCommunication   targetConnection        = new TargetCommunication();
            RealTimeModel         realTimeModelProperties = new RealTimeModel();
            RealTimeMonitor       realTimeMonitor         = new RealTimeMonitor();
            SimulationEnvironment simulationState         = new SimulationEnvironment();
            TargetFileSystem      targetFileSystem        = new TargetFileSystem();
            RealTimeLogging       realTimeLogger          = new RealTimeLogging();

            CommunicationController communicationController = new CommunicationController(mainScreen, targetConnection);
            RealTimeModelController realTimeModelController = new RealTimeModelController(mainScreen, targetConnection, realTimeModelProperties, simulationState);
            ApplicationController   applicationController   = new ApplicationController(mainScreen, targetConnection, realTimeModelProperties, realTimeMonitor, simulationState);
            FileSystemController    fileSystemController    = new FileSystemController(mainScreen, targetConnection, targetFileSystem, realTimeLogger, simulationState);

            Application.Run(mainScreen);
        }
예제 #14
0
        public void Should_Initialize_Empty_Doors_With_No_Prizes_Even_With_Some_Doors_With_Prizes()
        {
            // Arrange
            var doors = new List <IDoor>
            {
                new Door()
                {
                    ContainsPrize = true
                },
                new Door()
                {
                    ContainsPrize = true
                },
                new Door()
                {
                    ContainsPrize = true
                },
                new Door()
                {
                    ContainsPrize = true
                },
                new Door()
                {
                    ContainsPrize = true
                }
            };

            var gameshow = new SimulationEnvironment(doors);

            // Act
            gameshow.RemovePrizesFromAllDoors();

            var result = gameshow.Doors.All(d => d.ContainsPrize == false);

            // Assert
            Assert.True(result);
        }
 public override void OnInspectorGUI()
 {
     _simulationEnvironment = (SimulationEnvironment)target;
     DrawProblemField();
     GUILayout.Space(10);
 }
예제 #16
0
 protected override void AssertEnvironmentState(SimulationEnvironment environment)
 {
     Assert.Equal(MaxDuration, environment.Now);
 }
 public FluidsGenericCellGrower(IPlant plant, SimulationEnvironment environment,
                                ICellBodySystemSolver systemSolver, IPlantSimulatorOptionsService optionsService) : base(plant, environment,
                                                                                                                         systemSolver, optionsService)
 {
 }
예제 #18
0
 public MainController()
 {
     controller            = new ComponentController();
     simulationEnvironment = new SimulationEnvironment();
 }
예제 #19
0
 /// <summary>
 /// When overriden, verifies that state conditions for the simulation environment are met.
 /// </summary>
 /// <param name="environment">
 /// The simulation environment at the end of the simulation.
 /// </param>
 protected abstract void AssertEnvironmentState(SimulationEnvironment environment);