public Logic(Modes mode, string pathIn, string pathOut, string pathInfo) { UnityEngine.Object.Destroy(GameObject.Find("NEAT")); UnityEngine.Object.Destroy(GameObject.Find("NEAT_Canvas")); showControls = false; this.pathIn = pathIn; this.pathOut = pathOut; this.mode = mode; map = new Map(); float gamma; string[] values; FileStream fin = new FileStream(pathIn, FileMode.Open); using (StreamReader reader = new StreamReader(fin)) { values = reader.ReadLine().Split(';'); reader.ReadLine(); mapSize = new Vector3Int(Convert.ToInt32(values[1]), Convert.ToInt32(values[2]), Convert.ToInt32(values[3])); map.map = new char[mapSize.z, mapSize.y, mapSize.x]; for (int z = 0; z < mapSize.z; z++) { for (int y = 0; y < mapSize.y; y++) { values = reader.ReadLine().Split(';'); for (int x = 0; x < mapSize.x; x++) { map.map[z, y, x] = Convert.ToChar(values[x]); } } reader.ReadLine(); } } fin.Close(); FileStream finInfo = new FileStream(pathInfo, FileMode.Open); using (StreamReader reader = new StreamReader(finInfo)) { reader.ReadLine(); reader.ReadLine(); reader.ReadLine(); reader.ReadLine(); values = reader.ReadLine().Replace('.', ',').Split(';'); gamma = Convert.ToSingle(values[1]); values = reader.ReadLine().Split(';'); switch (Convert.ToInt32(values[1])) { case 0: iterations = mapSize.x * mapSize.y * mapSize.z; break; default: iterations = Convert.ToInt32(values[1]); break; } values = reader.ReadLine().Split(';'); repetitions = Convert.ToInt32(values[1]); values = reader.ReadLine().Split(';'); switch (Convert.ToInt32(values[1])) { case 0: visualization = VisualizationType.NOVISUALIZATION; break; case 1: visualization = VisualizationType.ITERATIONS; break; case 2: visualization = VisualizationType.STATES; break; } } finInfo.Close(); map.Initialize(mapSize); agent = GameObject.Find("QL_Start"); if (mode == Modes.LEARN) { initialsK = 0; repetitionsK = 0; finishReward = mapSize.x * mapSize.y * mapSize.z; table = new Table(finishReward, mapSize, map, gamma); UnityEngine.Object.Destroy(GameObject.FindWithTag("StartPositions")); if (visualization == VisualizationType.NOVISUALIZATION) { UnityEngine.Object.Destroy(agent); for (int i = 0; i < map.Spaces.Count; i++) { UnityEngine.Object.Destroy(map.Spaces[i]); } for (int i = 0; i < map.Walls.Count; i++) { UnityEngine.Object.Destroy(map.Walls[i]); } UnityEngine.Object.Destroy(map.Finish); UnityEngine.Object.Destroy(GameObject.FindWithTag("Walls")); UnityEngine.Object.Destroy(GameObject.FindWithTag("StartPositions")); GameObject.FindWithTag("MainCamera").GetComponent <CameraMovement>().enabled = false; } } else if (mode == Modes.CHECK) { pos_agents = new List <GameObject>(); agent.SetActive(false); moves = new List <Vector3>(); table = new Table(finishReward, mapSize, map, gamma); FileStream fresult = new FileStream(pathOut, FileMode.Open); using (StreamReader reader = new StreamReader(fresult)) { for (int action = 0; action < mapSize.x * mapSize.y * mapSize.z; action++) { string[] bits = reader.ReadLine().Split(';'); for (int state = 0; state < mapSize.x * mapSize.y * mapSize.z; state++) { table.Q[action, state] = Convert.ToInt64(bits[state]); } } } fresult.Close(); for (int i = 0; i < map.Spaces.Count; i++) { bool notThere = true; for (int j = 0; j < map.Walls.Count; j++) { notThere &= map.Spaces[i] != map.Walls[j]; } if (notThere && map.Spaces[i] != map.Finish) { GameObject.FindWithTag("StartPositions").GetComponent <Dropdown>().options.Add(new Dropdown.OptionData { text = map.Spaces[i].name }); } } UnityEngine.Object.Destroy(GameObject.FindWithTag("TextPosition")); UnityEngine.Object.Destroy(GameObject.FindWithTag("TextRepetition")); GameObject.FindWithTag("TextControls").GetComponent <RectTransform>().transform.localPosition = new Vector3(-205.35f, 230.3f, 0.0f); } for (int j = 0; j < map.Walls.Count; j++) { GameObject.FindWithTag("Walls").GetComponent <Dropdown>().options.Add(new Dropdown.OptionData { text = map.Walls[j].name }); } }