public void Simulate()
        {
            var request = new SimulationRequestModel
            {
                ProjectId           = 1,
                ResourceId          = 4,
                StatisticalEngineId = 1,
                CreatedBy           = "test user"
            };
            var expectedResult = new SimulationResponseModel()
            {
                NoOfModels    = 120,
                TimeInSeconds = 600
            };

            var projectService = new Mock <ISimulationService>();

            projectService.Setup(service => service.Simulate(request.ProjectId, request.ResourceId, request.StatisticalEngineId, request.CreatedBy))
            .Returns(expectedResult);
            var controller   = new SimulationController(projectService.Object);
            var actualResult = controller.Simulate(request);

            Assert.Equal(expectedResult.NoOfModels, actualResult.Value.NoOfModels);
            Assert.Equal(expectedResult.TimeInSeconds, actualResult.Value.TimeInSeconds);
        }
예제 #2
0
    public static void Init()
    {
        GameMath gameMath = new GameMath();

        gameMath.Init();
        SimulationController.Init(gameMath);
    }
예제 #3
0
    void Start()
    {
        _animator = GetComponent <Animator>();
        var simObj = GameObject.FindWithTag("simulationController");

        _simulationController = simObj.GetComponent <SimulationController>();
    }
예제 #4
0
        private void btn_Start_Click(object sender, EventArgs e)
        {
            Thread t = new Thread(
                () =>
            {
                int x = 0;
                foreach (var configuration in RunConfigurationFactory.GetConfigurations())
                {
                    btn_Start.Invoke(new Action(() => { btn_Start.Enabled = false; }));
                    Global.UpdateTime(configuration.SimulationSize, configuration.Strategy);
                    SimulationController controller = new SimulationController(configuration);
                    controller.StartSimulation();
                    accountingResultsManager.WriteDataToDisk(controller.AccountingModuleObject.MeasureHolder);
                    if (x != configuration.TrialId)
                    {
                        x = configuration.TrialId;
                        WriteLastIndex(x);
                    }
                    Thread.Sleep(5000);
                    btn_Start.Invoke(new Action(() =>
                    {
                        AddDataHolder(controller.AccountingModuleObject.MeasureHolder);
                        btn_Start.Enabled = true;
                    }));
                }
            });

            t.Priority = ThreadPriority.Highest;
            t.Start();
        }
    public TimeController(SimulationController controller) : base(controller)
    {
        // Self-register to the unity messaging
        Simulation simulation = Simulation.Instance;

        simulation.AddHook(this);
    }
예제 #6
0
        private void DeleteModelButton_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow Row in ModelsStateTable.SelectedRows)
            {
                string ModelName = (string)Row.Cells[0].Value;

                int ModelIndex = SimulationController.FindModelIndex(ModelName);
                ModelsResultsPages.TabPages.RemoveAt(ModelIndex);

                TabPage ModelPage = (TabPage)Pages.Controls.Find(ModelPageName + ModelName, true)[0];
                Pages.Controls.Remove(ModelPage);

                SimulationController.DeleteModel(ModelName);

                SimulationController.ModelsStates.RemoveAt(ModelIndex);
                ModelsStateTable.Rows.RemoveAt(ModelIndex);
            }

            if (SimulationController.Models.Count == 0)
            {
                DeleteModelButton.Enabled     = false;
                StartSimulationButton.Enabled = false;
            }

            ModelsStateTable.ClearSelection();
        }
예제 #7
0
    /// <summary>
    /// Initialization
    /// </summary>
    void Start()
    {
        GameObject simControllerObject = GameObject.Find("SimulationController");

        if (simControllerObject)
        {
            simController = simControllerObject.GetComponent <SimulationController>();
        }

        height = gameObject.GetComponent <MeshFilter>().mesh.bounds.size.z;
        width  = gameObject.GetComponent <MeshFilter>().mesh.bounds.size.x;

        field         = GameObject.FindGameObjectWithTag("Field").GetComponent <IField>();
        linerenderers = new LineRenderer[2 * iterations];

        for (int i = 0; i < iterations * 2; i++)
        {
            GameObject line = new GameObject("line");
            line.transform.parent = this.transform;
            //line.transform.localRotation = Quaternion.identity;

            LineRenderer linerenderer = line.AddComponent <LineRenderer>();
            //linerenderer.useWorldSpace = false;
            linerenderer.shadowCastingMode = ShadowCastingMode.On;
            linerenderer.receiveShadows    = true;
            linerenderer.material          = ironMaterial;
            linerenderer.lightProbeUsage   = LightProbeUsage.Off;
            linerenderer.startWidth        = lineStartWidth;
            linerenderer.endWidth          = lineEndWidth;
            linerenderers[i] = linerenderer;
        }
        gameObject.SetActive(false);
    }
예제 #8
0
        private void StopModelButton_Click(object sender, EventArgs e)
        {
            int NumErrors = 0;

            foreach (DataGridViewRow Row in ModelsStateTable.SelectedRows)
            {
                string ModelName  = (string)Row.Cells[0].Value;
                int    ModelIndex = SimulationController.FindModelIndex(ModelName);

                try
                {
                    if (!SimulationController.ModelsProcesses[ModelIndex].HasExited)
                    {
                        SimulationController.ModelsProcesses[ModelIndex].Kill();
                    }
                }
                catch (Exception KillException)
                {
                    ToLogsTextBox("Process kill error: " + KillException.Message);
                    NumErrors++;
                }
            }

            if (NumErrors != 0)
            {
                MessageBox.Show(NumErrors.ToString() + " errors occured at attempt to stop model(s) simulation process", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            ModelsStateTable.ClearSelection();
        }
예제 #9
0
    // Use this for initialization
    void Start()
    {
        if (instance != null)
        {
            Debug.LogError("Multiple instances of singleton!");
        }

        // TODO: Implement a safer singleton
        instance = this;

        // Create the simulation controller instance
        controller = new SimulationController();

        // Add some core components.
        controller.AddSimulationComponent <SimulationSceneController>();
        controller.AddSimulationComponent <VideoController>();
        controller.AddSimulationComponent <UIController>();
        controller.AddSimulationComponent <TimelineController>();
        controller.AddSimulationComponent <DecisionController>();
        controller.AddSimulationComponent <FeedbackController>();
        controller.AddSimulationComponent <ParticleController>();
        controller.AddSimulationComponent <MenuController>();
        controller.AddSimulationComponent <AudioController>();

        controller.AddSimulationComponent <TimeController>();
        //timeController.SetTimeLimit(80);

        // Initialize the simulation.
        controller.Initialize();
    }
        private void Initialize(ILevelControllerOptions options)
        {
            // Constructs all the in-level components, then stores the ones that'll be needed later in member variables.
            // Done this way rather than directly initializing the member variables because this way if they're reordered,
            // the compiler will complain if something's being constructed before its dependency.
            var surface    = GeodesicSphereFactory.Build(options);
            var simulation = new SimulationController(surface, options);

            var cameraController = new CameraController(options);

            var meshManager      = new MeshManager(surface);
            var cursorTracker    = new CursorTracker(cameraController.Camera, meshManager);
            var fieldManipulator = new FieldManipulator(surface, cursorTracker, options);

            var colorMapView     = new ColorMapView(surface, meshManager.Mesh, options);
            var particleMapView  = new ParticleMapView(surface, options);
            var rawValuesView    = new RawValuesView(cursorTracker);
            var timeDilationView = new TimeView(50, options.Timestep);
            var latLongGridView  = new LatLongGridView(options.Radius);

            _simulationController = simulation;
            _colorMapView         = colorMapView;
            _particleMapView      = particleMapView;
            _rawValuesView        = rawValuesView;
            _timeView             = timeDilationView;
            _latLongGridView      = latLongGridView;
            _cameraController     = cameraController;
            _cursorTracker        = cursorTracker;
            _fieldManipulator     = fieldManipulator;
        }
예제 #11
0
        public void Post_Game_ReturnsSimulationResults(int NumberOfSimulations, int nrWins)
        {
            var simulationResultObj = new SimulationResult()
            {
                wins             = nrWins,
                percentageOfWins = (decimal)(nrWins / NumberOfSimulations),
                losses           = NumberOfSimulations - nrWins,
                NumberOfDoors    = 3,
            };
            var mockSimulationService = new Mock <ISimulationService>();

            mockSimulationService.Setup(service => service.RunSimulation(It.IsAny <int>(), It.IsAny <Boolean>(), It.IsAny <int>())).Returns(simulationResultObj);
            var sut = new SimulationController(mockSimulationService.Object);

            var result = sut.Post(new Game()
            {
                NumberOfSimulations = NumberOfSimulations
            }) as OkObjectResult;

            Assert.IsInstanceOf <OkObjectResult>(result);

            var simulationResult = result.Value as SimulationResult;

            Assert.GreaterOrEqual(simulationResult.wins, nrWins);
            Assert.GreaterOrEqual(simulationResult.losses, simulationResultObj.losses);
            Assert.GreaterOrEqual(simulationResult.percentageOfWins, simulationResultObj.percentageOfWins);
            Assert.AreEqual(simulationResult.NumberOfDoors, simulationResultObj.NumberOfDoors);
        }
예제 #12
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            LoggerSetup();

            EntityLoader loader = new EntityLoader();

            loader.LoadFromFile(filePath);

            List <DisplayableElement> displayableGrid  = EntityDisplayConverter.ToDisplayableElements(loader.grid.SelectMany(node => node).ToList <IPosition>());
            List <DisplayableElement> displayableRooms = EntityDisplayConverter.ToDisplayableElements(loader.rooms.ToList <IPosition>());
            SimulationForm            simulationForm   = new SimulationForm(displayableGrid, displayableRooms);

            SimulationController controller = new SimulationController(simulationForm, loader.grid, loader.movableEntities, loader.rooms);

            Console.WriteLine("Starting Setup:");
            Console.WriteLine("Seed file: {0}", filePath);
            Console.WriteLine("Simulation with {0} people", loader.movableEntities.Count);

            // close event from the GUI
            simulationForm.onCloseEvent += (object sender, EventArgs e) => controller.Dispose();
            // close event from the console
            AppDomain.CurrentDomain.ProcessExit += new EventHandler((object sender, EventArgs e) => controller.Dispose());

            Thread controllerThread = new Thread(controller.start);

            simulationForm.onShowEvent += new EventHandler((object sender, EventArgs e) => controllerThread.Start());

            Application.Run(simulationForm);
        }
예제 #13
0
 void Start()
 {
     simulationController = SimulationController.Instance;
     if (simulationController.IsSimulationActive())
     {
         playBackArea.SetActive(true);
     }
 }
 private void Awake()
 {
     controller = GameObject.Find("App").GetComponent <SimulationController>();
     timeSlider = transform.Find("Time").transform.Find("Slider").GetComponent <Slider>();
     SetTime(timeSlider.value);
     speedSlider = transform.Find("Speed").transform.Find("Slider").GetComponent <Slider>();
     SetSpeed(speedSlider.value);
 }
        public void TestPastState()
        {
            var restoredController = new SimulationController <SimpleEmptyCheck>(true, path);
            var firstStep          = restoredController.Load(0);

            Assert.AreEqual(2, firstStep.TopGroup.B.GetMarks().Count);
            Assert.AreEqual(0, firstStep.TopGroup.C.GetMarks().Count);
        }
예제 #16
0
 protected virtual void Start()
 {
     SimController = FindObjectOfType <SimulationController>();
     if (!SimController)
     {
         throw new System.NullReferenceException("Simulation Controller is null");
     }
 }
예제 #17
0
        public Startup(IConfiguration configuration)
        {
            simulationController = new SimulationController();
            simulationController.AddModel(new WorldModel());
            simulationController.AddView(networkView);

            Configuration = configuration;
        }
예제 #18
0
    public override void ExecuteAction()
    {
        Simulation           sim                = Simulation.Instance;
        SimulationController controller         = sim.Controller;
        ParticleController   particleController = controller.GetSimulationComponent <ParticleController>();

        particleController.CreateParticles(_particleActions);
    }
 public ParticleController(SimulationController controller) : base(controller)
 {
     _particlePlayer = GameObject.FindObjectOfType <ParticlePlayer>();
     if (!_particlePlayer)
     {
         Debug.LogError("Particle player not found on scene!");
     }
 }
예제 #20
0
        public void Initialize()
        {
            _apManager       = new Mock <IAirplaneManager>();
            _flightDirector  = new Mock <IFlightDirector>();
            _airplaneSpawner = new Mock <IAirplaneSpawner>();
            _simProperties   = new Mock <ISimulationProperties>();

            _simController = new SimulationController(_apManager.Object, _flightDirector.Object, _airplaneSpawner.Object, _simProperties.Object);
        }
 public RedirectedUnit()
 {
     redirector = new Redirector();
     resetter   = new Resetter();
     controller = new SimulationController();
     resultData = new ResultData();
     id         = -1;
     status     = "UNDEFINED"; // TODO: 이래도 되나?
 }
예제 #22
0
    void Start()
    {
        var mngObject = GameObject.FindWithTag("simulationController");

        if (mngObject != null)
        {
            _simulationController = mngObject.GetComponent <SimulationController>();
        }
    }
예제 #23
0
    private void Start()
    {
        var simControllerObject = GameObject.Find("SimulationController");

        if (simControllerObject)
        {
            simController = simControllerObject.GetComponent <SimulationController>();
        }
    }
예제 #24
0
    protected virtual void Start()
    {
        GameObject simControllerObject = GameObject.Find("SimulationController");

        if (simControllerObject)
        {
            simController = simControllerObject.GetComponent <SimulationController>();
        }
    }
 public void init()
 {
     Controller = new SimulationController <SimpleEmptyCheck>(false, path);
     for (var i = 0; i < 5; i++)
     {
         Controller.SimulationStep();
     }
     Controller.Save();
 }
        public void WhenStartSimulation_ThenResultShouldHaveTenLegs()
        {
            var legs = 10;

            playerMock.Setup(x => x.PlayLeg(false)).Returns(new Leg());
            var controller = new SimulationController(playerMock.Object);
            var result     = controller.StartSimulation(legs, 100, 100, false, false);

            Approvals.Verify("Amount of Legs: " + result.Legs.Count);
        }
예제 #27
0
    public VideoController(SimulationController controller) : base(controller)
    {
        _videoPlayer = GameObject.FindObjectOfType <VideoPlayerLoader>();
        if (!_videoPlayer)
        {
            Debug.LogError("VideoPlayer not found on scene!");
        }

        _videoPlayer.finishedPlayingCurrentVideo += onVideoFinishedPlaying;
    }
    public TimelineController(SimulationController controller) : base(controller)
    {
        timeline = new Timeline();
        timeline.AddListener(this);

        // Self register and hook into the unity messages
        Simulation simulation = GameObject.FindObjectOfType <Simulation>();

        simulation.AddHook(this);
    }
예제 #29
0
        public Main()
        {
            InitializeComponent();
            simulationController = new SimulationController(new lcdControler(lcdControl1, lcdControl2, lcdControl3, lcdControl4));

            this.DataContext = simulationController.GuiDataValues;
            simulationController.GuiDataValues.UpdateFields();

            //memoryPreview.ItemsSource = guiData.EXT_RAM;
        }
 private void Start()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
     }
 }