public void Starting() { print($"/// Starting Controller with isSquare:{isSquare} ///"); //Spawn agent agent = Instantiate(agentPrefab, new Vector2(-999, -999), Quaternion.identity); //Get data from menu DQLearning = ManagerScenes.isDeepQN; isSquare = ManagerScenes.isSquare; if (!DQLearning) { agentQTable = agent.GetComponent <AgentQTable>(); agentQTable.enabled = true; agentQTable.controller = this; } else { agentDQL = agent.GetComponent <AgentDQL>(); agentDQL.enabled = true; agentDQL.controller = this; } epsilon = 1f; minEplison = 0.1f; epsilonDecay = 0.05f / (n + m); learningRate = 0.75f; discountRate = 0.85f; //3 times the diagonal (more less) length (sqrt(2)*size ~= 1.4*size) maxSteps = (int)Mathf.Sqrt((n * n + m * m)) * 3; nActions = isSquare ? ActionSquare.nAction : ActionHex.nAction; Restart(); }
void Start() { agentQTable = controller.agentQTable; agentDQL = controller.agentDQL; //Reward multiplier int r = 10; //Rewards should be normalized between -1 and 1 if (controller.DQLearning) { r = 1; } maxReward = 1 * r; minReward = 0.5f * r; punishment = -1 * r; //Larger is the platform size lower should be this value //Negative reward for each step -> minimize the steps required to reach the goal point empty = -0.1f * r; if (maxRewardPoint) { reward = maxReward; } else if (minRewardPoint) { reward = minReward; } else if (punishmentPoint) { reward = punishment; } else { reward = empty; } canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.worldCamera = Camera.main; if (isCube) { //Set the position of the texts of each platform in the 4 positions (Up,Right,Down,Left) //minvalue is the half size of a platform //Greater is the factor, farther is the text from the center float factor = 0.25f; text[0].transform.position = transform.position + new Vector3(0, minValue * factor); text[1].transform.position = transform.position + new Vector3(minValue * factor, 0); text[2].transform.position = transform.position + new Vector3(0, -minValue * factor); text[3].transform.position = transform.position + new Vector3(-minValue * factor, 0); text[4].enabled = false; //text[4].transform.position = transform.position; //text[4].text = (point.y * controller.size + point.x).ToString(); } else { //Set the position of the texts of each platform in the 6 positions (Up,RightUp,RightDown,Down,LeftDown,LeftUp) //minvalue is the half size of a platform //Greater is the factor, farther is the text from the center float factorTD = 0.35f; float factorLR = 0.2f; text[0].transform.position = transform.position + new Vector3(0, minValue * factorTD); text[1].transform.position = transform.position + new Vector3(minValue * factorLR, minValue * factorLR); text[2].transform.position = transform.position + new Vector3(minValue * factorLR, -minValue * factorLR); text[3].transform.position = transform.position + new Vector3(0, -minValue * factorTD); text[4].transform.position = transform.position + new Vector3(-minValue * factorLR, -minValue * factorLR); text[5].transform.position = transform.position + new Vector3(-minValue * factorLR, minValue * factorLR); text[6].enabled = false; text[6].transform.position = transform.position; text[6].text = (point.y * controller.n + point.x).ToString() + point; } for (int i = 0; i < text.Length; i++) { text[i].fontSize = 8; } }