public HeroMoveInfo(SimulationHero hero, HeroMove heroMove, float distance) { this.hero = hero; this.heroMove = heroMove; this.distance = distance; }
int PerformMiniMax(WorldGridState gridState, int depth, int alpha, int beta) { if (depth == 0 || gridState.IsGameOver()) { return(gridState.Evaluate()); } if (gridState.CurrentHero.HeroSide == UnitSide.MAX_UNIT) { List <HeroMove> legalMoves = gridState.GetLegalMoves(); gridState.EvaluateMoves(legalMoves); legalMoves = legalMoves.OrderByDescending(move => move.MoveEvaluation).ToList(); for (int i = 0, len = legalMoves.Count; i < len; ++i) { WorldGridState newGridState = new WorldGridState(gridState); newGridState.MoveHero(legalMoves[i]); int evaluation = PerformMiniMax(newGridState, depth - 1, alpha, beta); if (evaluation > alpha) { alpha = evaluation; if (depth == depthSearch) { bestHeroMove = legalMoves[i]; } } if (beta <= alpha) { break; } } return(alpha); } else { List <HeroMove> legalMoves = gridState.GetLegalMoves(); gridState.EvaluateMoves(legalMoves); legalMoves = legalMoves.OrderByDescending(move => move.MoveEvaluation).ToList(); for (int i = 0, len = legalMoves.Count; i < len; ++i) { WorldGridState newGridState = new WorldGridState(gridState); newGridState.MoveHero(legalMoves[i]); int evaluation = PerformMiniMax(newGridState, depth - 1, alpha, beta); if (evaluation < beta) { beta = evaluation; } if (beta <= alpha) { break; } } return(beta); } }