Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var e = new EvolutionStrategy();

            Console.WriteLine(e.Run());

menu:
            Menu();

start:
            var parameters = new List <object>();
            var methodName = Read();

            parameters.AddRange(_map.Values);

repeat:
            var watch = Stopwatch.StartNew();
            var result = Invoke(methodName, parameters);

            watch.Stop();

            result.Time = watch.ElapsedMilliseconds / 1000f;

            BoardHelper.Print(result, "Found board:");
            JsonHelper.WriteOutputFile(result, "output.json");

            Console.WriteLine("0. Powtorz");
            Console.WriteLine("1. Nowe");
            Console.WriteLine("2. Menu\n");
            var input = Console.ReadKey().KeyChar;

            Console.WriteLine("\n");
            if (input == '0')
            {
                goto repeat;
            }
            else if (input == '1')
            {
                goto start;
            }
            else if (input == '2')
            {
                goto menu;
            }
        }
Exemplo n.º 2
0
        public static Result BruteForce(BoardValues boardValues)
        {
            Console.WriteLine("---BRUTEFORCE---\n");

            var bestBoard = new bool[boardValues.RowCount, boardValues.ColumnCount];
            var minError  = int.MaxValue;

            Parallel.ForEach(Generator.GenerateCombinations(boardValues.RowCount, boardValues.ColumnCount), board =>
            {
                var error = BoardHelper.CheckForErrors(boardValues, board);

                if (error < minError)
                {
                    minError  = error;
                    bestBoard = board;
                }
            });

            return(new Result(bestBoard, boardValues));
        }