/// <summary> Estimates how good the given child state is. </summary> public static float GetStateValue(POGame parent, POGame child, PlayerTask task, TyStateAnalyzer analyzer) { float valueFactor = 1.0f; TyState myState = null; TyState enemyState = null; Controller player = null; Controller opponent = null; //it's a buggy state, mostly related to equipping/using weapons on heroes etc. //in this case use the old state and estimate the new state manually: if (child == null) { player = parent._game.CurrentPlayer; opponent = parent._game.CurrentOpponent; myState = TyState.FromSimulatedGame(parent, player, task); enemyState = TyState.FromSimulatedGame(parent, opponent, null); //if the correction failes, assume the task is x% better/worse: if (!TyState.CorrectBuggySimulation(myState, enemyState, parent, task)) { valueFactor = 1.25f; } } else { player = child._game.CurrentPlayer; opponent = child._game.CurrentOpponent; //happens sometimes even with/without TURN_END, idk if (!analyzer.IsMyPlayer(player)) { player = child._game.CurrentOpponent; opponent = child._game.CurrentPlayer; } myState = TyState.FromSimulatedGame(child, player, task); enemyState = TyState.FromSimulatedGame(child, opponent, null); } TyDebug.Assert(analyzer.IsMyPlayer(player)); TyDebug.Assert(!analyzer.IsMyPlayer(opponent)); return(analyzer.GetStateValue(myState, enemyState, player, opponent, task) * valueFactor); }