// ---------------------------------------------- // // ------------ Buttons Functions ----------- // // ---------------------------------------------- // public void RunExploration(bool simulation) { Arena.ClearBoard(); if (simulation) { string path = DEFAULT_MAP_PATH;; if (Application.isEditor) { //path = EditorUtility.OpenFilePanel("Load map file: ", "Assets/", "txt"); } if (path.Length > 0) { Arena.CreateBoard(false); startingPos = new Pos(1, 1); startingDir = Direction.EAST; Exploration._sensorBuffer = "-1,-1,-1,-1,1"; Exploration.Init(startingPos, startingDir, LoadMap(path)); } else { return; // didn't load map } } else { if (!connected) { return; // not connected to RPI } Arena.CreateBoard(false); Exploration.Init(startingPos, startingDir); } if (coveragePercentage < 100) // simulation: coverage { explorationThread = new Thread(new ThreadStart(Exploration.ExplorationAlgoCoverage)); } else if (hasTimeLimit) // simulation: time limit { explorationThread = new Thread(new ThreadStart(Exploration.ExplorationAlgoTimeLimit)); } else // real run & plain simulation { explorationThread = new Thread(new ThreadStart(Exploration.ExplorationAlgo)); } inExploration = true; hasCompleteMap = false; explorationThread.Start(); }
public void LoadMapFromFile() { Arena.ClearBoard(); string path = DEFAULT_MAP_PATH; if (Application.isEditor) { //path = EditorUtility.OpenFilePanel("Load map file: ", "Assets/", "txt"); } if (path.Length > 0) { gridStatuses = Arena.LoadMap(path); CreateVirtualWall(true); } else { Debug.LogError("Not able to open file! Loading default test map file. "); gridStatuses = Arena.LoadMap(DEFAULT_MAP_PATH); } Arena.CreateBoard(true); }