/// <summary> /// Create a system given the system view. This is used to restore the System for each Session /// </summary> /// <param name="systemView"></param> public System(SystemView systemView) { World = new World(systemView.Map); Dictionary <Camera, double> camerasOrientation = new Dictionary <Camera, double>(); foreach (CameraProperties cameraProp in systemView.Cameras) { //Correct the offset due to the addition of the walls in the system view Camera camera = new AngularCamera(cameraProp.X - 1, cameraProp.Y - 1); World.AddCamera(camera); camerasOrientation[camera] = cameraProp.Orientation; } // To remove if possible World.InitializeCameras(); _model = new MarkovModel(World); TrueState = new State(systemView.TrueState[0] - 1, systemView.TrueState[1] - 1, camerasOrientation); Distribution <State> d = new Distribution <State>(); // Ignore the first and last row/column to account for the offset caused by the outside walls for (int i = 1; i < systemView.Probabilities.Length - 1; i++) { for (int j = 1; j < systemView.Probabilities[i].Length - 1; j++) { if (systemView.Probabilities[i][j] > 0) { d.SetProba(new State(i - 1, j - 1, camerasOrientation), systemView.Probabilities[i][j]); } } } CurrentDistribution = d; }
public World GetEmptyWorld() { Map map = new Map(8, 8); World world = new World(map); Camera camera = new AngularCamera(0, 7); world.AddCamera(camera); return(world); }
/// <summary> /// Updates the system at a certain position, the update depend on the keyword passed with the position /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="cellType"></param> public void ModifyCell(int x, int y, string cellType) { if (!(World.Map.IsInMap(x, y))) { return; } switch (cellType) { case ("wall"): if (!(TrueState.X == x && TrueState.Y == y)) { World.Map.Cells[x, y] = new Wall(); } break; case ("glass"): if (!(TrueState.X == x && TrueState.Y == y)) { World.Map.Cells[x, y] = new Glass(); } break; case "target": if (World.Map.IsCellFree(x, y)) { TrueState.X = x; TrueState.Y = y; } break; case "camera": if (World.IsCamera(x, y, out Camera camera)) { RemoveCamera(camera); } else if (World.Map.IsCellFree(x, y)) { Camera newCamera = new AngularCamera(x, y); World.AddCamera(newCamera); TrueState.CamerasOrientations[newCamera] = 0d; } break; default: World.Map.Cells[x, y] = null; break; } InitializeSystem(); }
/// <summary> /// Builds the default world /// </summary> /// <returns></returns> public World GetDefaultWorld() { Map map = new Map(7, 7); map.AddObstacle(6, 4, new Wall()); map.AddObstacle(4, 4, new Wall()); map.AddObstacle(3, 4, new Wall()); map.AddObstacle(2, 4, new Wall()); map.AddObstacle(2, 3, new Wall()); map.AddObstacle(2, 2, new Wall()); map.AddObstacle(2, 0, new Wall()); World world = new World(map); Camera camera = new AngularCamera(0, 6); world.AddCamera(camera); return(world); }
/// <summary> /// Build a template world /// </summary> /// <returns></returns> public World GetMuseumWorld() { Map map = new Map(11, 11); map.AddObstacle(3, 0, new Wall()); map.AddObstacle(3, 1, new Wall()); map.AddObstacle(3, 3, new Wall()); map.AddObstacle(3, 4, new Wall()); map.AddObstacle(3, 5, new Wall()); map.AddObstacle(2, 5, new Wall()); map.AddObstacle(0, 5, new Wall()); map.AddObstacle(7, 0, new Wall()); map.AddObstacle(7, 1, new Wall()); map.AddObstacle(7, 3, new Wall()); map.AddObstacle(7, 4, new Wall()); map.AddObstacle(7, 5, new Wall()); map.AddObstacle(8, 5, new Wall()); map.AddObstacle(10, 5, new Wall()); map.AddObstacle(0, 8, new Wall()); map.AddObstacle(2, 8, new Wall()); map.AddObstacle(3, 8, new Wall()); map.AddObstacle(3, 9, new Wall()); map.AddObstacle(10, 8, new Wall()); map.AddObstacle(8, 8, new Wall()); map.AddObstacle(7, 8, new Wall()); map.AddObstacle(7, 9, new Wall()); map.AddObstacle(4, 5, new Glass()); map.AddObstacle(5, 5, new Glass()); map.AddObstacle(6, 5, new Glass()); World world = new World(map); Camera camera = new AngularCamera(5, 7); world.AddCamera(camera); return(world); }