/// <summary> /// Compute score for attacking a target. /// </summary> /// <param name="sceneContext">The RockSceneContext</param> /// <param name="sourceRockId">The RockId of attacker</param> /// <param name="targetRockId">The RockId of target</param> /// <returns>The score in double</returns> private static double ScoreForMinionAttackHero(RockSceneContext sceneContext, int sourceRockId, int targetRockId) { var targetHero = sceneContext.GetRockHero(targetRockId); var sourceMinion = sceneContext.GetRockMinion(sourceRockId); double score = 4d; bool canKill = sourceMinion.Damage >= targetHero.Health; if (canKill) { score += 4; } else { score += sourceMinion.Damage; } return(score); }
/// <summary> /// Compute score for attacking a target. /// </summary> /// <param name="sceneContext">The RockSceneContext</param> /// <param name="sourceRockId">The RockId of attacker</param> /// <param name="targetRockId">The RockId of target</param> /// <returns>The score in double</returns> private static double ScoreForMinionAttack(RockSceneContext sceneContext, int sourceRockId, int targetRockId) { var targetMinion = sceneContext.GetRockMinion(targetRockId); var sourceMinion = sceneContext.GetRockMinion(sourceRockId); double score = 0d; bool canKill = false; if (!targetMinion.HasDivineShield) { canKill = sourceMinion.Damage >= targetMinion.Health; } bool canSurvive = true; if (!sourceMinion.HasDivineShield) { canSurvive = targetMinion.Damage <= sourceMinion.Health; } double benifit = Math.Pow(targetMinion.Damage, 1.5d) + targetMinion.Health - Math.Pow(sourceMinion.Damage, 1.5d) - sourceMinion.Health; if (targetMinion.HasWindfury) { benifit += targetMinion.Damage; } if (sourceMinion.HasWindfury) { benifit -= sourceMinion.Damage; } if (targetMinion.HasAura) { benifit += 2; } if (sourceMinion.HasAura) { benifit -= 2; } if (sourceMinion.HasTaunt) { benifit -= 2; } if (canKill) { score += targetMinion.Damage; } else if (canSurvive) { score += sourceMinion.Damage; } if (canKill && canSurvive) { score += benifit; } else if (!canKill && canSurvive) { score += benifit * 0.625; } else if (canKill && !canSurvive) { score += benifit * 0.475; } else { score += benifit * 0.125; if (sourceMinion.HasAura) { score -= 2; } if (sourceMinion.HasTaunt) { score -= 2; } // !canKill && !canSurvive score += 0; } return(score); }