public Solution Extend(Solution other)
        {
            ISet <int> newWinningRegion = new HashSet <int>(this.winningRegion);

            newWinningRegion.UnionWith(other.winningRegion);
            PositionalStrategy newStrategy = this.strategy;

            foreach (int from in other.strategy.GetDomain().Where(node => !winningRegion.Contains(node)))
            {
                newStrategy.Update(from, other.strategy.GetNextMove(from));
            }
            return(new Solution(newWinningRegion, newStrategy));
        }
        public Solution ComputeWinningRegionOne(ReachabilityGame game)
        {
            ISet<int> winningRegionZero = ComputeWinningRegionZero(game).getWinningRegion();
            ISet<int> winningRegionOne = game.GetArena().GetNodes();
            winningRegionOne.ExceptWith(winningRegionZero);
            PositionalStrategy tau = new PositionalStrategy();
            foreach (var p1Node in winningRegionOne.Where(node => game.GetArena().IsPlayerOneNode(node)))
            {
                var nextNodeEnumerator = game.GetArena().GetSuccessors(p1Node).Where(node => !winningRegionZero.Contains(node)).AsEnumerable().GetEnumerator();
                nextNodeEnumerator.MoveNext();
                tau.Update(p1Node, nextNodeEnumerator.Current);
            }

            return new Solution(winningRegionOne, tau);
        }
 public Solution CPreOne(ISet<int> target)
 {
     var retVal = new HashSet<int>();
     // Speaking in math: retVal += { cand \in V_0 | forall (v, v') \in E. v = cand => v' \in target }
     retVal.UnionWith(from cand in playerZeroNodes where edges.All(edge => edge.Item1 != cand || target.Contains(edge.Item2)) select cand);
     // Speaking in math: retVal += { cand \in V_1 | exists (v, v') \in E. v = cand && v' \in target }
     retVal.UnionWith(from cand in playerOneNodes where edges.Any(edge => edge.Item1 == cand && target.Contains(edge.Item2)) select cand);
     var tau = new PositionalStrategy();
     foreach(var p1Node in retVal.Where(node => IsPlayerOneNode(node)))
     {
         var targetEnumerator = target.Where(potentialTargetNode => GetSuccessors(p1Node).Contains(potentialTargetNode)).AsEnumerable().GetEnumerator();
         targetEnumerator.MoveNext();
         tau.Update(p1Node, targetEnumerator.Current);
     }
     return new Solution(retVal, tau);
 }
Esempio n. 4
0
        public Solution ComputeWinningRegionOne(ReachabilityGame game)
        {
            ISet <int> winningRegionZero = ComputeWinningRegionZero(game).getWinningRegion();
            ISet <int> winningRegionOne  = game.GetArena().GetNodes();

            winningRegionOne.ExceptWith(winningRegionZero);
            PositionalStrategy tau = new PositionalStrategy();

            foreach (var p1Node in winningRegionOne.Where(node => game.GetArena().IsPlayerOneNode(node)))
            {
                var nextNodeEnumerator = game.GetArena().GetSuccessors(p1Node).Where(node => !winningRegionZero.Contains(node)).AsEnumerable().GetEnumerator();
                nextNodeEnumerator.MoveNext();
                tau.Update(p1Node, nextNodeEnumerator.Current);
            }

            return(new Solution(winningRegionOne, tau));
        }
        public Solution CPreOne(ISet <int> target)
        {
            var retVal = new HashSet <int>();

            // Speaking in math: retVal += { cand \in V_0 | forall (v, v') \in E. v = cand => v' \in target }
            retVal.UnionWith(from cand in playerZeroNodes where edges.All(edge => edge.Item1 != cand || target.Contains(edge.Item2)) select cand);
            // Speaking in math: retVal += { cand \in V_1 | exists (v, v') \in E. v = cand && v' \in target }
            retVal.UnionWith(from cand in playerOneNodes where edges.Any(edge => edge.Item1 == cand && target.Contains(edge.Item2)) select cand);
            var tau = new PositionalStrategy();

            foreach (var p1Node in retVal.Where(node => IsPlayerOneNode(node)))
            {
                var targetEnumerator = target.Where(potentialTargetNode => GetSuccessors(p1Node).Contains(potentialTargetNode)).AsEnumerable().GetEnumerator();
                targetEnumerator.MoveNext();
                tau.Update(p1Node, targetEnumerator.Current);
            }
            return(new Solution(retVal, tau));
        }
 public Solution(ISet<int> winningRegion, PositionalStrategy strategy)
 {
     this.strategy = strategy;
     this.winningRegion = winningRegion;
 }
 public Solution(ISet <int> winningRegion, PositionalStrategy strategy)
 {
     this.strategy      = strategy;
     this.winningRegion = winningRegion;
 }