public SimulateResults GetSimulate( string type, IBestPlayerStrategy strategy, EsquemaPosicoes esquemaPosicoes, IList <JogadorHistorico> jogadores = null) { var result = new SimulateResults() { Type = $"{type} [{esquemaPosicoes.Esquema.Nome}]", Results = CalculateResults(jogadores ?? _players, strategy, esquemaPosicoes) .ToList() }; result.Mean = result.Results.Sum(x => x.Score) / result.Results.Count; result.TotalScore = result.Results.Sum(x => x.Score); result.PriceMean = result.Results.Sum(x => x.TeamPrice) / result.Results.Count(x => x.TeamPrice > 0); result.EsquemaId = esquemaPosicoes.EsquemaId; result.EsquemaNome = esquemaPosicoes.Esquema.Nome; return(result); }
private IEnumerable <Partial> CalculatePhase(int size, SimulateResults result, string type, string phaseName = null) { var havePhaseName = string.IsNullOrWhiteSpace(phaseName) == false; for (int initialRound = 1; initialRound <= result.Results.Max(x => x.Round); initialRound += size) { var finalRound = initialRound + size - 1; var partials = result.Results.Where(x => x.Round >= initialRound && x.Round <= finalRound); yield return(new Partial() { Type = type, InitialRound = initialRound, FinalRound = finalRound, Phase = $"{(havePhaseName ? phaseName + " - " : "")}Between round {initialRound} and {finalRound} ({result.Type}).", Mean = partials.Sum(x => x.Score) / partials.Count(), PriceMean = partials.Sum(x => x.TeamPrice) / partials.Count(x => x.TeamPrice > 0), TotalScore = partials.Sum(x => x.Score), EsquemaId = result.EsquemaId, EsquemaNome = result.EsquemaNome }); } }