Пример #1
0
        internal bool AnyWinningStrategiesUnderNode(StrategyNode node)
        {
            if (node.Level == 3)
            {
                return(node.WeighPoint.Knowledge.FoundHeavyCoin || node.WeighPoint.Knowledge.FoundLightCoin || node.WeighPoint.Knowledge.AllAreEven);
            }

            return
                (node.IfLeftWins.Any(AnyWinningStrategiesUnderNode) ||
                 node.IfRightWins.Any(AnyWinningStrategiesUnderNode) ||
                 node.IfEven.Any(AnyWinningStrategiesUnderNode));
        }
Пример #2
0
        internal void ExecuteWeighPointOnNode(StrategyNode node)
        {
            if (node.Level > 3)
            {
                return;
            }

            var weighPoint = node.WeighPoint;

            node.IfLeftWins  = GetAllStrategies(weighPoint.SupposeLeftWins(), node /*parentNode*/);
            node.IfRightWins = GetAllStrategies(weighPoint.SupposeRightWins(), node /*parentNode*/);
            node.IfEven      = GetAllStrategies(weighPoint.SupposeEven(), node /*parentNode*/);
        }
Пример #3
0
        internal List <StrategyNode> GetAllStrategies(Knowledge knowledge, StrategyNode parentNode = null)
        {
            List <StrategyNode> roots = ComputeWeighPoints(knowledge).Select(
                balance => new StrategyNode(new WeighPoint(knowledge, balance), parentNode)
                ).ToList();

            foreach (var node in roots)
            {
                Console.WriteLine($"Execute | {node.Level}");
                ExecuteWeighPointOnNode(node);
            }

            return(roots);
        }
Пример #4
0
 internal StrategyNode(WeighPoint weighPoint, StrategyNode parent)
 {
     WeighPoint = weighPoint;
     Parent     = parent;
 }
Пример #5
0
 internal StrategyNode(WeighPoint weighPoint)
 {
     WeighPoint = weighPoint;
     Parent     = null;
 }