private double EvaluatorShot() { double evaluation = 0; // large bonus for proximity to goal (1,e). Vector2d goalPosition = Constants.Uprights[0]; //upper-left post if (!_owner.Team.AttackingLeft) { goalPosition = Constants.Uprights[2]; //upper-right post } Vector2d goalVector = goalPosition - _owner.PositionDouble; double maxShotDistance = 2000; if (goalVector.Length() < maxShotDistance) { evaluation += Math.Pow(Math.E, (1 - goalVector.Length() / maxShotDistance)); } // large bonus for clear line of shot // add large bonus if lane of passing is empty (0,3). List <Coords> lane = _owner.InhabitedMap.RayTracer(_owner.PositionOnInfMap(), StaticMathFunctions.PositionOnFieldToInfMapCoords(goalPosition)); InfluenceMap enemyMap = _owner.EnemyTeam.TeamInfluenceMap; double interdiction = 0; for (int i = 0; i < lane.Count; ++i) { // these should be weighted somehow double toAdd = enemyMap.GetMapValue(lane[i]); if (toAdd > 0.7) { evaluation += toAdd; } } if (interdiction < 3) { evaluation += (3 - interdiction); } // there should be a bonus for easy shots // there should be a monster bonus for when the GK is out of position return(evaluation); }
/// <summary> /// Returns a double that measures the usefulness of a ground pass to passTarget /// </summary> private double EvaluatorPassGround(Footballer passTarget) { double evaluation = 0; Vector2d passVector = passTarget.PositionDouble - _owner.PositionDouble; // add bonus for short passes (1,e) evaluation += Math.Pow(Math.E, (1 - passVector.Length() / Constants.ActualXMax)); // add bonus for going in the direction of enemy goal (0,1) Vector2d goalPosition = Constants.Uprights[0]; //upper-left post if (!_owner.Team.AttackingLeft) { goalPosition = Constants.Uprights[2]; //upper-right post } double angle = passVector.AngleBetween(goalPosition - _owner.PositionDouble); angle = Math.Abs(angle - Math.PI); evaluation += (angle / Math.PI); // add large bonus if lane of passing is empty (0 or 3). List <Coords> lane = _owner.InhabitedMap.RayTracer(_owner.PositionOnInfMap(), passTarget.PositionOnInfMap()); InfluenceMap enemyMap = _owner.EnemyTeam.TeamInfluenceMap; double interdiction = 0; for (int i = 0; i < lane.Count; ++i) { // these should be weighted somehow double toAdd = enemyMap.GetMapValue(lane[i]); if (toAdd > 0.5) { evaluation += toAdd; } } if (interdiction == 0) { evaluation += 3; } // there should be a bonus for players making runs return(evaluation); }