IEnumerator AICycle() { if (typeAI != AIType.Montecarlo) { yield return(null); Actions act = AI.Decide(); yield return(null); myEffector.Execute(act); } else { MontecarloAI aux = (MontecarloAI)AI; aux.MontecarloDecide(currentGame.GetSnapshot()); while (!aux.Ready) { yield return(null); } #if UNITY_EDITOR if (aux.ActionToExecute == Actions.None) { Debug.LogError("ERROR EN MONTECARLO: NO SE HA OBTENIDO ACCION"); } #endif myEffector.Execute(aux.ActionToExecute); } }
/// <summary> /// Initilices the class creating a tree but does NOT start the simulation /// </summary> /// <param name="playerId">Id of the player that will execute the tree</param> /// <param name="support">Montecarlo AI instance that will receive the results</param> /// <param name="executionTime">Miliseconds the simulation will take. Default = 1500</param> public MontecarloTT(int playerId, MontecarloAI support, float executionTime = GlobalData.MONTECARLO_TIMER_MILISECONDS) { timeToPlay = executionTime; id = playerId; int dummy; ThreadPool.GetMaxThreads(out maxSimulations, out dummy); maxSimulations -= 2; mMutex = new Mutex(); this.support = support; }