private void Pause_Continue() { if (paused) { paused = false; Clock.Instance.Continue(); Time.timeScale = 1f; } else { paused = true; Clock.Instance.Stop(); Time.timeScale = 0f; //PRUEBAS ARBOL MONTECARLO MontecarloTree tree = new MontecarloTree(currentGame.GetSnapshot(), 0); M_Node aux; for (int i = 0; i < 200; i++) { aux = tree.SearchForNextNode(); aux.Score += Random.Range(-10, 10); Debug.Log("El nodo " + aux.Position + " tiene ahora " + aux.Score + " puntos"); tree.BackpropagateScore(aux); } //DebugSnapshot(currentGame.GetSnapshot()); // DebugSnapshot(currentGame.GetSnapshot().TakeAndGetSnapshot()); //TestAdvanceTurnAndExecuteAction(); } }
private void Simulate(System.Object info) { M_FlowController flow = new M_FlowController(id); M_Node node = (M_Node)info; //Debug.Log("Empezando entrenamiento de nodo " + node.Position); flow.StartTrainingInThisThread(node.State); #if UNITY_EDITOR if (node.State.SomeoneWon() == GlobalData.NO_PLAYER) { Debug.LogError("NADIE GANO AL EJECUTAR LA SIMULACION"); } #endif if (flow.currentWinner == id) { //Debug.Log("Terminando entrenamiento de nodo " + node.Position); node.Score += GlobalData.MONTECARLO_REWARD; } else if (flow.currentWinner != GlobalData.TIE) { node.Score += GlobalData.MONTECARLO_PENALIZATION; } else { node.Score = 0; } node.Score += flow.RatioExtraScore * 2; // Debug.Log("Terminando entrenamiento de nodo " + node.Position + " con " + node.Score + " puntos" ); tree.BackpropagateScore(node); node.State.RestoreSnapshot(); mMutex.WaitOne(); currentActiveSimulations--; mMutex.ReleaseMutex(); }