コード例 #1
0
        public void PrintLargeSiteOverview()
        {
            var strb = new StringBuilder();

            for (int i = 0; i < _algo.N; i++)
            {
                for (int x = 0; x < _algo.N; x++)
                {
                    if (x == 0)
                    {
                        strb.Append(i.ToString().PadLeft(3) + ": ");
                    }

                    if (_algo.IsInPercolationPath(i * _algo.N + x))
                    {
                        strb.Append("x");
                    }
                    else if (_algo.IsSiteOpen(i, x))
                    {
                        strb.Append(".");
                    }
                    else
                    {
                        strb.Append(" ");
                    }
                }

                strb.AppendLine();
            }

            strb.Append(PrintStatistics());

            File.AppendAllText(_outputFileName, strb.ToString());
        }
コード例 #2
0
        public void PrintLargeSiteOverview()
        {
            Console.Clear();

            for (int i = 0; i < _algo.N; i++)
            {
                for (int x = 0; x < _algo.N; x++)
                {
                    if (x == 0)
                    {
                        Console.Write(i.ToString().PadLeft(3) + ": ");
                    }

                    if (_algo.IsInPercolationPath(i * _algo.N + x))
                    {
                        var c = i < _algo.N * 0.33 ? ConsoleColor.Yellow :
                                i < _algo.N * 0.66 ? ConsoleColor.Red :
                                ConsoleColor.DarkRed;

                        //Console.BackgroundColor = (ConsoleColor)new Random(new object().GetHashCode()).Next(12, 15);
                        PrintColoredSpace(c);
                    }
                    //else if (_sites[i, x] == true)
                    else if (_algo.IsSiteOpen(i, x))
                    {
                        //Console.BackgroundColor = (ConsoleColor)new Random(new object().GetHashCode()).Next(1, 3);
                        PrintColoredSpace(ConsoleColor.DarkCyan);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }

                Console.WriteLine();
            }

            PrintStatistics();
        }