Advertisement
Guest User

RNG_CONSOLE_NOISE

a guest
Mar 26th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 20.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Stop_It
  8. {
  9.     class Program
  10.     {
  11.         static string title_init = "";
  12.         static string dir = System.IO.Directory.GetCurrentDirectory();
  13.         static string path = System.IO.Path.GetFullPath(dir);
  14.         //static System.Threading.Thread Time_Thread = new System.Threading.Thread(Ticked);
  15.         //static System.Timers.Timer time = new System.Timers.Timer();
  16.         //delegate void ChangeTitleCallback(string title);
  17.         static void Main(string[] args)
  18.         {
  19.             int store_color;
  20.             //int fileno=0;
  21.             int duration = 1000;
  22.             //int count_change = 0;
  23.             //int Forecolor_cycles = 0;
  24.             /*bool[] is_Changed = new bool[3];
  25.             is_Changed[0] = false;
  26.             is_Changed[1] = false;
  27.             is_Changed[2] = false;*/
  28.             title_init = args.Length == 1 ? args[0] : "";
  29.             ConsoleColor[] colors = new ConsoleColor[16];
  30.             colors[0] = ConsoleColor.Black;
  31.             colors[1] = ConsoleColor.Blue;
  32.             colors[2] = ConsoleColor.Cyan;
  33.             colors[3] = ConsoleColor.DarkBlue;
  34.             colors[4] = ConsoleColor.DarkCyan;
  35.             colors[5] = ConsoleColor.DarkGray;
  36.             colors[6] = ConsoleColor.DarkGreen;
  37.             colors[7] = ConsoleColor.DarkMagenta;
  38.             colors[8] = ConsoleColor.DarkRed;
  39.             colors[9] = ConsoleColor.DarkYellow;
  40.             colors[10] = ConsoleColor.Gray;
  41.             colors[11] = ConsoleColor.Green;
  42.             colors[12] = ConsoleColor.Magenta;
  43.             colors[13] = ConsoleColor.Red;
  44.             colors[14] = ConsoleColor.White;
  45.             colors[15] = ConsoleColor.Yellow;
  46.             string[] filler = new string[Console.WindowWidth];
  47.             for (int wi = 0; wi < Console.WindowWidth; wi++)
  48.             {
  49.                 filler[wi] = "_";
  50.             }
  51.             Int32[,,] tones = new Int32[100, 100, 2];
  52.             int s_index = tones.Length;
  53.             System.Random gen = new System.Random();
  54.             for (int z = 0; z < 2; z++)
  55.             {
  56.                 for (int i = 0; i < (tones.Length / 200); i++)
  57.                 {
  58.                     for (int index = 0; index < (tones.Length / 200); index++)
  59.                     {
  60.                         tones[i, index, z] = gen.Next(37, 1037);
  61.                     }
  62.                 }
  63.             }
  64.             for (int z = 0; z < 2; z++)
  65.             {
  66.                 for (int i = 0; i < (tones.Length / 200); i++)
  67.                 {
  68.                     for (int index = 0; index < (tones.Length / 200); index++)
  69.                     {
  70.                         if (z == 0 && tones[i, index, z] < tones[i, index, z + 1])
  71.                         {
  72.                             int temp_tone = tones[i, index, z];
  73.                             tones[i, index, z + 1] = tones[i, index, z];
  74.                             tones[i, index, z] = temp_tone;
  75.                         }
  76.                        
  77.                     }
  78.                 }
  79.             }
  80.             //time.Start();
  81.             System.IO.MemoryStream store = new System.IO.MemoryStream();
  82.             using (var ms = new System.IO.MemoryStream())
  83.             {
  84.                 var wl = new System.IO.StreamWriter(ms);
  85.                 do
  86.             {
  87.                 for (int z = 0; z < 2; z++)
  88.                 {
  89.                     int bc_index = 0;
  90.                     int c_index = 0;
  91.                         for (int last1 = tones.Length; last1 > 0; last1--)
  92.                         {
  93.                         int temp_i1 = last1 != 0 ? (last1 / 200) - 1 : 0;
  94.                             //fileno = temp_i1;
  95.                         for (int last = tones.Length; last > 0; last--)
  96.                         {
  97.                             int temp_i2 = last != 0 ? (last / 200) - 1 : 0;
  98.                             string filename1 = String.Format("tones{0}.txt", temp_i2);
  99.                             bc_index = bc_index < colors.Length ? bc_index : 0;
  100.                             c_index = c_index < colors.Length ? c_index : 0;
  101.                                 bc_index += temp_i2 != 99 ? 1:0;
  102.                                 //int bc_index = gen.Next(0,15);
  103.                                 System.IO.StreamWriter tw = new System.IO.StreamWriter(store);
  104.                                 Console.Clear();
  105.                                 Console.BackgroundColor = colors[bc_index];//!= Console.BackgroundColor ? colors[bc_index] : colors[gen.Next(0, 15)];
  106.                                 Console.Clear();
  107.                                 Console.BackgroundColor = colors[bc_index];//!= Console.BackgroundColor ? colors[bc_index] : colors[gen.Next(0, 15)];
  108.                                 //count_change += colors[c_index] == colors[bc_index] ? 1 : 0;
  109.                                 c_index+= c_index<colors.Length ? 1:0;
  110.                                 //int duration = gen.Next(25, 100);
  111.                                 //Console.Beep(tones[temp_i1, temp_i2, z_i], duration);
  112.                                 for (int hi = 0; hi < Console.WindowHeight; hi++)
  113.                                 {
  114.                                     store_color = c_index;
  115.                                     System.Random gen1 = new System.Random();
  116.                                     //int last_background = c_index;
  117.                                     c_index = c_index <= colors.Length - 1 ? c_index : 0;
  118.                                     int beep_length = gen1.Next(1, 20);
  119.                                     if (beep_length % 2 != 0)
  120.                                     {
  121.                                         int last_b = beep_length;
  122.                                         beep_length = gen1.Next(2, 20);
  123.                                         beep_length = beep_length != last_b ? beep_length : 8;
  124.                                     }
  125.                                     /*while (colors[bc_index] == colors[c_index])
  126.                                     {
  127.                                         /*while (last_background == c_index)
  128.                                         {
  129.                                             int c = gen.Next(0, 15);
  130.                                             c_index = c;
  131.                                             Console.BackgroundColor = colors[c_index];
  132.                                             Console.ForegroundColor = colors[c_index];
  133.                                             count_change += 1;
  134.                                         }
  135.                                         c_index++;
  136.                                         bc_index++;
  137.                                         Console.BackgroundColor = colors[c_index];
  138.                                         Console.ForegroundColor = colors[c_index];
  139.                                         /*if (count_change != 0)
  140.                                         {
  141.                                             beep_length = gen1.Next(1, 8);
  142.                                             Console.Beep(tones[temp_i1, temp_i2, z], duration / beep_length);
  143.                                         }
  144.                                         count_change++;
  145.                                         Forecolor_cycles += count_change == 2 ? 1 : 0;
  146.                                         if (count_change == 2) { if (!System.IO.File.Exists(path + @"\count.txt")) { System.IO.File.CreateText(path + @"\count.txt"); System.IO.StreamWriter sw = new System.IO.StreamWriter(path + @"\count.txt"); sw.WriteLine(Forecolor_cycles); bc_index++; sw.Dispose(); } System.IO.StreamWriter sw1 = new System.IO.StreamWriter(path + @"\count.txt"); sw1.WriteLine(Forecolor_cycles); bc_index++; sw1.Dispose(); }
  147.                                         count_change = count_change == 16 ? 0 : count_change;*/
  148.                                     Console.BackgroundColor = colors[c_index];
  149.                                     Console.ForegroundColor = colors[c_index];
  150.                                     bool changed2 = false;
  151.                                     while (changed2 == false)
  152.                                     {
  153.                                         Console.BackgroundColor = Console.BackgroundColor != colors[bc_index] ? Console.BackgroundColor : colors[gen1.Next(0, 15)];
  154.                                         if (Console.BackgroundColor == colors[bc_index])
  155.                                         {
  156.                                             Console.BackgroundColor = colors[gen.Next(0, 15)];
  157.                                             changed2 = Console.BackgroundColor != colors[bc_index];
  158.                                         }
  159.                                         changed2 = Console.BackgroundColor != colors[bc_index];
  160.                                     }
  161.                                     for (int wi = 0; wi < Console.WindowWidth; wi++)
  162.                                     {
  163.                                         int z_i = gen.Next(0, 1);
  164.                                         int rand_x = gen1.Next(0, temp_i1);
  165.                                         int rand_y = gen1.Next(0, temp_i2);
  166.                                         if (tones[rand_x, rand_y, z_i] % 4 == 0)
  167.                                         {
  168.                                             bool changed = false;
  169.                                             int shift_1 = gen.Next(1, 4);
  170.                                             //rand_x = gen.Next(0, temp_i1);
  171.                                             //rand_y = gen.Next(0, temp_i2);
  172.                                             beep_length = shift_1;
  173.                                             ConsoleColor current = Console.BackgroundColor;
  174.                                             Console.BackgroundColor = colors[gen.Next(0, 15)];
  175.                                             while (changed == false)
  176.                                             {
  177.                                                 Console.BackgroundColor = colors[gen.Next(0, 15)];
  178.                                                 if (Console.BackgroundColor == colors[c_index])
  179.                                                 {
  180.                                                     Console.BackgroundColor = colors[gen.Next(0, 15)];
  181.                                                     changed = Console.BackgroundColor != colors[c_index] && Console.BackgroundColor != colors[bc_index];
  182.                                                 }
  183.                                                 changed = Console.BackgroundColor != colors[c_index] && Console.BackgroundColor != colors[bc_index];
  184.                                             }
  185.                                             /*while (Console.BackgroundColor == colors[c_index])
  186.                                             {
  187.                                                 //ConsoleColor clast = Console.BackgroundColor;
  188.                                                 Console.BackgroundColor = colors[gen.Next(0, 15)];
  189.                                                 Console.BackgroundColor = Console.BackgroundColor != colors[c_index] ? Console.BackgroundColor : colors[gen.Next(0, 15)];
  190.                                                 while (Console.BackgroundColor == colors[bc_index])
  191.                                                 {
  192.                                                     Console.BackgroundColor = colors[gen.Next(0, 15)];
  193.                                                     Console.BackgroundColor = Console.BackgroundColor != colors[bc_index] ? Console.BackgroundColor : colors[gen.Next(0, 15)];
  194.                                                 }
  195.                                             }
  196.                                             while (Console.BackgroundColor == colors[bc_index])
  197.                                             {
  198.                                                 while (Console.BackgroundColor == colors[c_index])
  199.                                                 {
  200.                                                     Console.BackgroundColor = colors[gen.Next(0, 15)];
  201.                                                     Console.BackgroundColor = Console.BackgroundColor != colors[c_index] ? Console.BackgroundColor : colors[gen.Next(0, 15)];
  202.                                                 }
  203.                                                 Console.BackgroundColor = colors[gen.Next(0, 15)];
  204.                                                 Console.BackgroundColor = Console.BackgroundColor != colors[c_index] ? Console.BackgroundColor : colors[gen.Next(0, 15)];
  205.                                             }*/
  206.                                             Console.Write(" ");
  207.                                             wl.Write(" ");
  208.                                             Console.BackgroundColor = current;
  209.                                             tw.WriteLine(tones[rand_x, rand_y, z_i]);
  210.                                             Console.Beep(tones[rand_x, rand_y, z_i], duration / beep_length);
  211.                                             rand_x = gen.Next(0, temp_i1);
  212.                                             rand_y = gen.Next(0, temp_i2);
  213.                                         }
  214.                                         else if (tones[rand_x, rand_y, z_i] % 9 == 0)
  215.                                         {
  216.                                             bool changed = false;
  217.                                             int shift_1 = gen.Next(4, 9);
  218.                                             //rand_x = gen.Next(0, temp_i1);
  219.                                             //rand_y = gen.Next(0, temp_i1);
  220.                                             ConsoleColor current = Console.BackgroundColor;
  221.                                             beep_length = shift_1;
  222.                                             Console.BackgroundColor = colors[gen.Next(0, 15)];
  223.                                             while (changed == false)
  224.                                             {
  225.                                                 Console.BackgroundColor = colors[gen.Next(0, 15)];
  226.                                                 if (Console.BackgroundColor == colors[c_index])
  227.                                                 {
  228.                                                     Console.BackgroundColor = colors[gen.Next(0, 15)];
  229.                                                     changed = Console.BackgroundColor != colors[c_index] && Console.BackgroundColor != colors[bc_index];
  230.                                                 }
  231.                                                 changed = Console.BackgroundColor != colors[c_index] && Console.BackgroundColor != colors[bc_index];
  232.                                             }
  233.                                             Console.Write(" ");
  234.                                             wl.Write(" ");
  235.                                             Console.BackgroundColor = current;
  236.                                             tw.WriteLine(tones[rand_x, rand_y, z_i]);
  237.                                             Console.Beep(tones[rand_x, rand_y, z_i], duration / beep_length);
  238.                                             rand_x = gen.Next(0, temp_i1);
  239.                                             rand_y = gen.Next(0, temp_i2);
  240.                                         }
  241.                                         Console.Write(filler[wi]);
  242.                                         wl.Write(filler[wi]);
  243.                                         ChangeTitle();
  244.                                     }
  245.                                     //Console.Write("\n");
  246.                                     int z_in = gen.Next(0, 1);
  247.                                     int shift = gen1.Next(1, 12);
  248.                                     beep_length = shift;
  249.                                     Console.Beep(tones[temp_i1, temp_i2, z_in], duration / beep_length);
  250.                                     ChangeTitle();
  251.                                     bool changed1 = false;
  252.                                     bool isPrime = true;
  253.                                     for (int numbers = 1; numbers <= hi; numbers++)
  254.                                     {
  255.                                         int numbers_1 = numbers+2 > Console.WindowHeight ? numbers+2:numbers;
  256.                                         numbers_1 = numbers_1 != 1 ? numbers_1:numbers_1+1;
  257.                                         numbers_1 = numbers_1 != hi ? numbers_1 : hi + 1 > Console.WindowHeight ? hi + 1:hi-1;
  258.                                         if (hi % numbers_1 == 0)
  259.                                         {
  260.                                             isPrime = false;
  261.                                             break;
  262.                                         }  
  263.                                     }
  264.                                     if (isPrime)
  265.                                     {
  266.                                         Console.BackgroundColor = colors[store_color];
  267.                                     }
  268.                                     else if (!isPrime)
  269.                                     {
  270.                                         c_index = c_index < colors.Length ? c_index + 1 : 0;
  271.                                     }
  272.                                     while (changed1 == false)
  273.                                     {
  274.                                         Console.BackgroundColor = Console.BackgroundColor != colors[bc_index] ? Console.BackgroundColor:colors[gen1.Next(0,15)];
  275.                                         if (Console.BackgroundColor == colors[bc_index])
  276.                                         {
  277.                                             Console.BackgroundColor = colors[gen.Next(0, 15)];
  278.                                             changed1 = Console.BackgroundColor != colors[bc_index];
  279.                                         }
  280.                                         changed1 = Console.BackgroundColor != colors[bc_index];
  281.                                     }
  282.                                     //Console.Beep(tones[temp_i1, temp_i2, z_i], 30);
  283.                                 }
  284.                                 wl.Flush();
  285.                                 ms.Position = 0;
  286.                                 var sr = new System.IO.StreamReader(ms);
  287.                                 var myStr = sr.ReadToEnd();
  288.                                 string filename = String.Format("pattern{0}.txt", temp_i2);
  289.                                 System.IO.File.WriteAllText(path + @"\" + filename, myStr);
  290.                                 tw.Flush();
  291.                                 store.Position = 0;
  292.                                 var sr2 = new System.IO.StreamReader(store);
  293.                                 store.Position = 0;
  294.                                 myStr = sr2.ReadToEnd();
  295.                                 System.IO.File.WriteAllText(path + @"\" + filename1, myStr);
  296.                             }
  297.                           }
  298.                         }s_index--;
  299.                     }while (s_index != 0);
  300.                    
  301.                 }
  302.             }
  303.  
  304.                     public static void ChangeTitle()
  305.         {
  306.             if (title_init != "")
  307.             {
  308.                 ChangeTitle(title_init);
  309.             }
  310.             Random gen = new Random();
  311.             string title = Console.Title;
  312.             int index = 0;
  313.             char[] t_chars = title.ToCharArray();
  314.             title = "";
  315.             foreach (char a in t_chars)
  316.             {
  317.                 t_chars[index] = (char)gen.Next(((((int)a) * -1) + ((int)a)) + 33, 126);
  318.                 title += t_chars[index];
  319.                 index++;
  320.             }
  321.             index = 0;
  322.             Console.Title = title;
  323.         }
  324.         public static void ChangeTitle(string title)
  325.         {
  326.             Random gen = new Random();
  327.             int index = 0;
  328.             char[] t_chars = title.ToCharArray();
  329.             title = "";
  330.             foreach (char a in t_chars)
  331.             {
  332.                 t_chars[index] = (char)gen.Next(((((int)a) * -1) + ((int)a)) + 33, 126);
  333.                 title += t_chars[index];
  334.                 index++;
  335.             }
  336.             Console.Title = title;
  337.         }
  338.         /*public static void Ticked()
  339.         {
  340.             time.Start();
  341.             time.Elapsed += Time_Elapsed;
  342.         }
  343.  
  344.         private static void Time_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  345.         {
  346.             if(time.Interval < 100)
  347.             {
  348.                 time.Interval += 1;
  349.             }
  350.         }*/
  351.     }
  352. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement