using System.Diagnostics;
private static readonly Random Random = new Random();
private bool _measured = false;
public bool A { get; private set; }
public bool B { get; private set; }
public bool C { get; private set; }
public Particle(bool a, bool b, bool c)
public bool GetValue(int sensorPosition)
throw new InvalidOperationException("Измерить можно только один раз!");
throw new ArgumentOutOfRangeException();
public class EntanglementParticles
public Particle First { get; private set; }
public Particle Second { get; private set; }
public EntanglementParticles()
var firstParticleDegree = GetRandomInteger(0, 359);
int secondParticleDegree = (firstParticleDegree + 90) % 360;
bool a1 = IsDetectedBySensor(1, firstParticleDegree);
bool b1 = IsDetectedBySensor(2, firstParticleDegree);
bool c1 = IsDetectedBySensor(3, firstParticleDegree);
bool a2 = IsDetectedBySensor(1, secondParticleDegree);
bool b2 = IsDetectedBySensor(2, secondParticleDegree);
bool c2 = IsDetectedBySensor(3, secondParticleDegree);
if (a1 == a2 || b1 == b2 || c1 == c2)
Debug.Fail("a1 == a2 || b1 == b2 || c1 == c2");
First = new Particle(a1, b1, c1);
Second = new Particle(a2, b2, c2);
private static bool IsDetectedBySensor(int sensorPosition, int degree)
if (degree >= 0 && degree <= 89 ||
degree >= 180 && degree <= 269)
if (degree >= 0 && degree <= 29 ||
degree >= 120 && degree <= 209 ||
degree >= 300 && degree <= 359)
if (degree >= 60 && degree <= 149 ||
degree >= 240 && degree <= 329)
public static void Main(string[] args)
private static void Experiment1()
var totalAttempts = 10000;
for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++)
var entanglementParticles = new EntanglementParticles();
int firstSensorPosition = 1;
int secondSensorPosition = 1;
bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition);
bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition);
if (firstValue != secondValue)
Console.WriteLine("Эксперимент №1: {0}% значений не совпало", (decimal)disparityCount / totalAttempts * 100);
private static void Experiment2()
var totalAttempts = 10000;
for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++)
var entanglementParticles = new EntanglementParticles();
int firstSensorPosition = GetRandomInteger(1, 3);
int secondSensorPosition = GetRandomInteger(1, 3);
bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition);
bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition);
if (firstValue != secondValue)
Console.WriteLine("Эксперимент №2: {0}% значений не совпало", (decimal)disparityCount / totalAttempts * 100);
private static bool GetRandomBoolean()
return GetRandomInteger(0, 1) == 1;
private static int GetRandomInteger(int from, int to)
return Random.Next(from, to + 1);