public List <string> CreateUniquePath(Formation formation)
        {
            this.formation = formation;

            this.uniquePaths = new List <string>();
            if (this.GotFromJson(formation.Pattern))
            {
                return(this.uniquePaths);
            }

            Console.WriteLine("Building unique paths - START");

            this.GetUniques();

            Console.WriteLine("Building unique paths - DONE ");

            return(this.uniquePaths);
        }
Example #2
0
        public void BuildPerfectSquad(Formation formation, List <string> permutations)
        {
            this.result    = new FormationResult();
            this.formation = formation;
            // this.GetFromPlayersFromEa();
            this.SetPlayersToMemory();

            //EDMAR - ALL PLAYERS MUST COME FROM ABOVE
            //this.players = this.players.Where(p => p.Club != "Icons" && !p.IsSpecialType && p.Color == "rare_gold" && p.Rating > 78 && p.League.ToLower().StartsWith("pre")).ToList();
            this.players = this.players.Where(p => p.Club != "Icons" && !p.IsSpecialType && p.Color == "rare_gold" && p.Rating > 78 && p.Rating < 99).ToList();

            // Removing players that have positions that are not in this formation
            var allPositions = this.formation.Positions.Select(pos => pos.PositionEnum).Distinct().ToList();

            this.players = this.players.Where(pl => allPositions.Contains(pl.Position)).ToList();

            this.players = this.players.OrderByDescending(p => p.Rating).ToList();

            this.BuildSquad(permutations);
        }
Example #3
0
        private void BuildSquad()
        {
            this.players   = this.players.OrderByDescending(p => p.Rating).ToList();
            this.players   = this.players.Where(p => p.Rating > 78 && p.Rating <= 86).ToList();
            this.formation = new Formation("4-3-3");
            var topTen = this.players.Take(50);

            foreach (var player in topTen)
            {
                var position = this.formation.Positions.FirstOrDefault(p => p.PositionEnum == player.Position);
                if (position == null)
                {
                    continue;
                }

                var status = this.Setup(position, player);

                if (status == "ERROR")
                {
                    continue;
                }

                // CONSOLE.WRITE RESULTS
                Console.WriteLine("------------------[" + position.PositionEnum + "][" + player.Name + "]-------------------------");

                var soma = 0;
                foreach (var pos in this.formation.Positions)
                {
                    soma = soma + pos.Player.Rating;
                    Console.WriteLine("[" + pos.Player.Rating + "][" + pos.PositionEnum + "] " + pos.Player.Name);
                }

                Console.WriteLine("Rating Geral: [" + (soma / 11) + "]");


                // CLEANING POSITIONS
                foreach (var pos in this.formation.Positions)
                {
                    pos.Player = null;
                }
            }

            foreach (var position in this.formation.Positions)
            {
                Player firstPlayer = this.players.FirstOrDefault(pl => pl.Position == position.PositionEnum);

                var status = this.Setup(position, firstPlayer);

                if (status == "ERROR")
                {
                    continue;
                }

                // CONSOLE.WRITE RESULTS
                Console.WriteLine("------------------[" + position.PositionEnum + "]-------------------------");
                var soma = 0;
                foreach (var pos in this.formation.Positions)
                {
                    soma = soma + pos.Player.Rating;
                    Console.WriteLine("[" + pos.Player.Rating + "][" + pos.PositionEnum + "] " + pos.Player.Name);
                }

                Console.WriteLine("Rating Geral: [" + (soma / 11) + "]");

                // CLEANING POSITIONS
                foreach (var pos in this.formation.Positions)
                {
                    pos.Player = null;
                }
            }

            Console.WriteLine("______________________________________COMPLETED______________________________________");
        }