public override IEnumerable<PlayerRecommendation> Analyse(Player player, Fixture fixture, SimulationContext context) { if (Mapper == null) throw new ArgumentException("Invalid property", nameof(Mapper)); var res = new PlayerRecommendation(); res.Type = PlayerRecommendationType.ChanceOfPlaying; // old: //// Negatives //if (player.Fantasy.ChanceOfPlayingNextFixture >= 0) //{ // if (player.Fantasy.ChanceOfPlayingNextFixture <= 0) // res.Points = -10; // else if (player.Fantasy.ChanceOfPlayingNextFixture <= 0.25) // res.Points = -3; // else if (player.Fantasy.ChanceOfPlayingNextFixture <= 0.50) // res.Points = -2; // else if (player.Fantasy.ChanceOfPlayingNextFixture <= 0.75) // res.Points = -1; //} var valueMap = new ValueMap(); valueMap["percentage"] = player.Fantasy.ChanceOfPlayingNextFixture; res.Points = Mapper.Test(valueMap).Sum(x => x.Points); yield return res; }
public override IEnumerable<PlayerRecommendation> Analyse(Player player, Fixture fixture, SimulationContext context) { if (PointMapper == null) throw new ArgumentException("Invalid property", nameof(PointMapper)); var res = new PlayerRecommendation(); res.Type = PlayerRecommendationType.PlayerPlaytime; var playerTeam = player.GetLeagueTeam(fixture); double teamPlayedMinutes = playerTeam.GetPlayedMinutesBeforeFixtureForTeam(fixture); double playerMinutes = player.GetPlayedMinutesBeforeFixtureForPlayer(fixture); var percentage = teamPlayedMinutes > 0 ? playerMinutes / teamPlayedMinutes : 0; var valueMap = new ValueMap(); valueMap["minutes"] = playerMinutes; valueMap["percentage"] = percentage; //valueMap["playedgames"] = ; //valueMap["substitutes-in"] = ; //valueMap["substitutes-out"] = ; // todo: add more data points (subs, recent playtime (5 last team games), recent subs) res.Points = PointMapper.Test(valueMap).Sum(x => x.Points); yield return res; }
public void AddRecommendation(PlayerRecommendation recommendation) { //if (!PlayerRecommendations.ContainsKey(type)) // PlayerRecommendations.Add(type, 0); //PlayerRecommendations[type] += value; PlayerRecommendations.Add(recommendation); }
public override IEnumerable<PlayerRecommendation> Analyse(Player player, Fixture fixture, SimulationContext context) { var res = new PlayerRecommendation(); res.Type = PlayerRecommendationType.PlayerUnavailable; var unavailable = player.Fantasy.Unavailable; if (unavailable) res.Points = Points; yield return res; }
public override IEnumerable<PlayerRecommendation> Analyse(Player player, Fixture fixture, SimulationContext context) { if (Mapper == null) throw new ArgumentException("Invalid property", nameof(Mapper)); var res = new PlayerRecommendation(); res.Type = PlayerRecommendationType.PlayerPosition; var valueMap = context.GeneratePlayerValueMap(player, fixture, this); //res.Points = Mapper.Test(valueMap).Sum(x => x.Points); var pointRanges = Mapper.Test(valueMap).ToList(); var pointMappers = pointRanges.Select(x => x.Mapper).ToList(); var pointMappings = pointMappers.SelectMany(x => x.Test(valueMap)).ToList(); res.Points = pointMappings.Sum(x => x.Points); yield return res; }