private static readonly Random Random = new Random();
private Particle _superluminalChannel;
private int? _measuredPosition;
public bool? A { get; private set; }
public bool? B { get; private set; }
public bool? C { get; private set; }
internal void CreateSuperluminalChannelWith(Particle particle)
_superluminalChannel = particle;
public bool GetValue(int sensorPosition)
if (null != _measuredPosition)
throw new InvalidOperationException("Измерить можно только один раз!");
_measuredPosition = sensorPosition;
if (null != _superluminalChannel._measuredPosition)
var measuredValue = _superluminalChannel.GetNakedValue();
if (sensorPosition == _superluminalChannel._measuredPosition)
if (GetRandomInteger(1, 4) == 1)
var value = GetRandomBoolean();
SetValue(sensorPosition, value);
private bool GetNakedValue()
if (null == _measuredPosition)
throw new InvalidOperationException();
switch (_measuredPosition.Value)
throw new InvalidOperationException();
private void SetValue(int position, bool value)
throw new ArgumentOutOfRangeException();
public class EntanglementParticles
public Particle First { get; private set; }
public Particle Second { get; private set; }
public EntanglementParticles()
First.CreateSuperluminalChannelWith(Second);
Second.CreateSuperluminalChannelWith(First);
public static void Main(string[] args)
private static void Experiment1()
var totalAttempts = 10000;
var coincidenceCount = 0;
for (int attemptNumber = 1; attemptNumber <= totalAttempts; attemptNumber++)
var entanglementParticles = new EntanglementParticles();
var position = GetRandomInteger(1, 3);
int firstSensorPosition = position;
int secondSensorPosition = position;
bool firstValue = entanglementParticles.First.GetValue(firstSensorPosition);
bool secondValue = entanglementParticles.Second.GetValue(secondSensorPosition);
if (firstValue == secondValue)
Console.WriteLine("Эксперимент №1: {0}% значений совпало", (decimal)coincidenceCount / totalAttempts * 100);
private static void Experiment2()
var totalAttempts = 10000;
var coincidenceCount = 0;
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)coincidenceCount / 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);