/// <summary> /// Simulation constructor. /// </summary> /// <param name="mSystemObjects">Deserialized M System objects.</param> /// <exception cref="ArgumentException"> /// If M System objects objecst list is null. /// </exception> protected SimulationWorld(DeserializedObjects mSystemObjects) { if (mSystemObjects == null) { throw new ArgumentException("M System objects can't be null"); } SimulationMSystem = new MSystem(mSystemObjects); TilesWorld = new TilesWorld(SimulationMSystem); FltObjectsWorld = new FloatingObjectsWorld(SimulationMSystem, TilesWorld); // The TilesWorld and FltObjectsWorld need to crossref. TilesWorld.FltObjectsWorld = FltObjectsWorld; }
/// <summary> /// Constructor of the floating objects world. /// DO NOT USE outside the class SimulationWorld. /// </summary> /// <param name="mSystem">Simulated M system.</param> /// <param name="tilesWorld">World of tiles present initially in the P system</param>ra public FloatingObjectsWorld(MSystem mSystem, TilesWorld tilesWorld) { v_MSystem = mSystem; v_tilesWorld = tilesWorld; // Degree of granularity of the simulation space - objects are collected in these cubes // The constant 2.02 guarantees that each "floating object mobility" ball in space fits in // at most 2x2x2 grid cubes, plus 1% reserve. var cubeSize = mSystem.Mobility * 2.02; v_BoundaryVector = new Vector3D(cubeSize, cubeSize, cubeSize); v_Grid = new Dictionary <ulong, FloatingObjectsBar>(); // Calculate a bounding box around the seed tiles // THESE THREE COMMANDS MUST BE IN THIS ORDER!!! v_WorldBox = new Box3D(v_tilesWorld.SelectMany(tile => tile.Vertices)); v_GridKeys = new FloatingObjectsWorldKeys(cubeSize); ExpandWith(v_WorldBox); }