static void Main(string[] args)
        {
            var t      = 0;
            var same   = 0;
            var random = new Random();

            // We initialize a Quantum Simulator same as before
            using (var qsim = new QuantumSimulator())
            {
                // We run a loop for 1000 times to test the phenomenon
                for (int i = 0; i < 1000; i++)
                {
                    // Randomly generate boolean values to send as messages
                    var sentMessage = random.Next(2) == 0;
                    // We run the Superposition operation and store the returned result in the respective varialble
                    var receivedMessage = Teleportation.Run(qsim, sentMessage).Result;
                    // Check the ditribution of trues and false
                    if (receivedMessage)
                    {
                        t++;
                    }
                    // Confirm if the sent and received messages are the same.
                    if (sentMessage == receivedMessage)
                    {
                        same++;
                    }
                }
            }
            // Print the desired results
            Console.WriteLine("Teleportation Result: ");
            Console.WriteLine($"True: {t}");
            Console.WriteLine($"False: {1000 - t}");
            Console.WriteLine($"Same: {same / 1000 * 100}%");
            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var trues  = 0;
            var equal  = 0;
            var random = new Random();

            using (var qsim = new QuantumSimulator())
            {
                for (int index = 0; index < 1000; index++)
                {
                    var sentMessage     = random.Next(2) == 0; //get t/f bool
                    var receivedMessage = Teleportation.Run(qsim, sentMessage).Result;

                    if (receivedMessage)
                    {
                        trues++;
                    }

                    if (sentMessage == receivedMessage)
                    {
                        equal++;
                    }
                }
            }

            Console.WriteLine("Teleportation result: ");
            Console.WriteLine($"\t True: {trues}");
            Console.WriteLine($"\t False: {1000-trues}");
            Console.WriteLine($"\t Equal: {equal/1000*100}");
            Console.ReadKey();
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     using (var qsim = new QuantumSimulator())
     {
         var res = Teleportation.Run(qsim, 10000).Result;
         var(prob_0, prob_1) = res;
         System.Console.WriteLine(
             $"The probabilities of getting 0 and 1 are {prob_0/10000.0} and {prob_1/10000.0}");
         Console.WriteLine("Press any key to continue...");
         Console.ReadKey();
     }
 }