public bool setMap() { // Create the map based on the file this.mapModel = MapGenetic.read(mapPath.text); // Setting map to view if (this.GetComponent <MapGeneticView>() != null) { this.GetComponent <MapGeneticView>().MapModel = this.mapModel; this.GetComponent <MapGeneticView>().MapController = this; } this.mapModel.Graph.floydWarshall(); // Calculate all paths // Setting graph to genetic controller cities = new List <SalesmanCity>(); for (int i = 0; i < mapModel.Targets.Count; i++) { // For each target, create a city indicating the index of the vertex cities.Add(new SalesmanCity(i, mapModel.getCharacterGraphPosition(mapModel.Targets[i]))); } geneticController = GetComponent <GeneticSceneController>(); geneticController.setGraph(this.mapModel.Graph, cities); //this.selectShowSolutionMode( showBestSolution ); return(this.mapModel != null); }
public static MapGenetic readFromFile(string fileName) { string path = fileName; // UNCOMMENT FOR FIXED MAP FILES : WEB BUILD //return Map.read( Resources.Load<TextAsset>( fileName ).text ); // Starting Reader System.IO.StreamReader reader; try{ reader = new System.IO.StreamReader(path); } catch (System.Exception ex) { Debug.LogError("Error while opening the Map file"); Debug.LogError(ex.Message); return(null); } // Reading Information return(MapGenetic.read(reader.ReadToEnd())); }