public override void InitializeAgent() { MazeGeneratorArea = GetComponentInParent <MazeGeneratorArea>(); PlayerGoal = MazeGeneratorArea.PlayerGoal; RayPerception3D = GetComponent <RayPerception3D>(); if (CaptureData) { if (!MazeGeneratorArea.PlayerFileCreated) { var headings = new List <string>() { "PlayerName", "PlayerType", "StepsTrained", "MazeGeneratorName", "AverageScore", "MistakesMade", "LevelsComplted", "Score", "TotalMillisecondsToComplete" }; DataRecorder.WriteRecordToCSV(headings, CSVFilePath); MazeGeneratorArea.PlayerFileCreated = true; } } startTime = DateTime.UtcNow; }
public static MazeCell[,] InitializeMaze(GameObject agent, int mazeRows, int mazeColumns, GameObject wallPrefab, GameObject cellLocationPrefab, float cellSize, MazeGeneratorArea mazeGeneratorArea, GameObject playerGoal) { MazeCell[,] mazeCells = new MazeCell[mazeRows, mazeColumns]; for (int r = 0; r < mazeRows; r++) { for (int c = 0; c < mazeColumns; c++) { mazeCells[r, c] = new MazeCell { cellParentAndLocation = Instantiate(cellLocationPrefab, agent.transform.position + new Vector3(r * cellSize, 0, c * cellSize), Quaternion.identity, agent.transform) as GameObject }; mazeCells[r, c].cellParentAndLocation.name = $"Cell [{r},{c}]"; mazeCells[r, c].cellParentAndLocation.AddComponent <MazeCellValues>(); if (c == 0) { mazeCells[r, c].leftWall = Instantiate(wallPrefab, agent.transform.position + new Vector3(r * cellSize, 0, (c * cellSize) - (cellSize / 2f)), Quaternion.identity, mazeCells[r, c].cellParentAndLocation.transform) as GameObject; mazeCells[r, c].leftWall.name = "Left Wall " + r + "," + c; } mazeCells[r, c].rightWall = Instantiate(wallPrefab, agent.transform.position + new Vector3(r * cellSize, 0, (c * cellSize) + (cellSize / 2f)), Quaternion.identity, mazeCells[r, c].cellParentAndLocation.transform) as GameObject; mazeCells[r, c].rightWall.name = "Right Wall " + r + "," + c; if (r == 0) { mazeCells[r, c].topWall = Instantiate(wallPrefab, agent.transform.position + new Vector3((r * cellSize) - (cellSize / 2f), 0, c * cellSize), Quaternion.identity, mazeCells[r, c].cellParentAndLocation.transform) as GameObject; mazeCells[r, c].topWall.name = "Top Wall " + r + "," + c; mazeCells[r, c].topWall.transform.Rotate(Vector3.up * 90f); } mazeCells[r, c].bottomWall = Instantiate(wallPrefab, agent.transform.position + new Vector3((r * cellSize) + (cellSize / 2f), 0, c * cellSize), Quaternion.identity, mazeCells[r, c].cellParentAndLocation.transform) as GameObject; mazeCells[r, c].bottomWall.name = "Bottom Wall " + r + "," + c; mazeCells[r, c].bottomWall.transform.Rotate(Vector3.up * 90f); } } mazeGeneratorArea.MazeGeneratorPlayerAgent.transform.position = mazeCells[0, 0].cellParentAndLocation.transform.position; var temp = Instantiate(mazeGeneratorArea.MazeGeneratorPlayerAgent.gameObject, agent.transform.parent); Destroy(mazeGeneratorArea.MazeGeneratorPlayerAgent.gameObject); mazeGeneratorArea.MazeGeneratorPlayerAgent = temp.GetComponent <PCGMazeGeneratorPlayerAgent>(); mazeGeneratorArea.MazeGeneratorPlayerAgent.currentCell = mazeCells[0, 0]; playerGoal.transform.position = mazeCells[mazeRows - 1, mazeColumns - 1].cellParentAndLocation.transform.position; return(mazeCells); }
public override void InitializeAgent() { PCGMazeGeneratorArea = GetComponentInParent <MazeGeneratorArea>(); PlayerGoal = PCGMazeGeneratorArea.PlayerGoal; RayPerception3D = GetComponent <RayPerception3D>(); }