/// <summary> /// Returns a double that measures the usefulness of a lob pass to passTarget /// </summary> private double EvaluatorPassLob(Footballer passTarget) { double evaluation = 0; Vector2d passVector = passTarget.PositionDouble - _owner.PositionDouble; // add bonus for long passes (0,1) evaluation += 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 target is alone. InfluenceMap enemyMap = _owner.EnemyTeam.TeamInfluenceMap; double interdiction = enemyMap.SumInArea(passTarget.PositionOnInfMap(), (UInt16)(passVector.Length() / (0.1 * Constants.ActualXMax) + 1)); if (interdiction < 1) { evaluation += 3; } 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); }