src/strategy/Parity3.java
private static TreeSet<Integer> solveOneTwoSubgame(Game game, TreeSet<Integer> states, TreeMap<Integer,TreeSet<Integer>> allowed) {
		if (states.size() == 0) return new TreeSet<Integer>();
		
		TreeSet<Integer> remaining = new TreeSet<Integer>(states);
		Boolean wrnonzero;
		do {
			wrnonzero = false;
			TreeSet<Integer> targets = new TreeSet<Integer>();
			for (Integer key : remaining)
				if (game.states.get(key).parity == 1)
					targets.add(key);
			
			Ranks.subgame(game, remaining, targets, 2);
			
			TreeSet<Integer> p1winningregion = new TreeSet<Integer>();
			for (Integer key : remaining)
				if (game.states.get(key).rank == -1)
					p1winningregion.add(key);
			
			if (p1winningregion.size() > 0) {
				// From some states P2 can't ensure reaching parity1 state
				// Find P1 attractor to these states
				// Don't update the P2 strategy
				wrnonzero = true;
				TreeSet<Integer> p1reacheswr = p1reachesWR(game, remaining, p1winningregion);
				remaining.removeAll(p1winningregion);
				remaining.removeAll(p1reacheswr);
			} else if (remaining.size() > 0) {
				// From all states P2 can ensure reaching parity1 state
				// Add the behavior of P2 in this region into the strategy
				for (Integer from : remaining)
					if (game.states.get(from).player == 2) {
						assert(!allowed.containsKey(from));
						
						if (game.states.get(from).rank > 0) { // nonzero, noninfinity
							for (Integer into : game.transitions.get(from))
								if (remaining.contains(into) && game.states.get(into).rank != -1 &&
									game.states.get(into).rank < game.states.get(from).rank) {
									if (!allowed.containsKey(from))
										allowed.put(from, new TreeSet<Integer>());
									allowed.get(from).add(into);
								}
						}
						
						if (game.states.get(from).rank == 0) { // zero
							for (Integer into : game.transitions.get(from))
								if (remaining.contains(into) && game.states.get(into).rank != -1) {
									if (!allowed.containsKey(from))
										allowed.put(from, new TreeSet<Integer>());
									allowed.get(from).add(into);
								}					
						}
						
						assert(allowed.containsKey(from));
					}
			}
		} while (wrnonzero && remaining.size() > 0);
				
		return remaining;
	}
/**
	 * Solves a 1/2 subgame
	 * @param game		The entire game
	 * @param states	State space of the 1/2 subgame
	 * @param allowed	Update P2 strategy here
	 * @return			Player 2 winning region
	 */
Solves a 1/2 subgame
@param game          The entire game
@param states        State space of the 1/2 subgame
@param allowed       Update P2 strategy here
@return                      Player 2 winning region
Solves a 1 / 2 subgame @param game The entire game @param states State space of the 1 / 2 subgame @param allowed Update P2 strategy here @return Player 2 winning region
private static TreeSet<Integer> solveOneTwoSubgame(Game game, TreeSet<Integer> states, TreeMap<Integer,TreeSet<Integer>> allowed) {
		if (states.size() == 0) return new TreeSet<Integer>();
		TreeSet<Integer> remaining = new TreeSet<Integer>(states);
		Boolean wrnonzero;
		do {
			wrnonzero = false;
			TreeSet<Integer> targets = new TreeSet<Integer>();
			for (Integer key : remaining)
				if (game.states.get(key).parity == 1)
					targets.add(key);
			Ranks.subgame(game, remaining, targets, 2);
			TreeSet<Integer> p1winningregion = new TreeSet<Integer>();
			for (Integer key : remaining)
				if (game.states.get(key).rank == -1)
					p1winningregion.add(key);
			if (p1winningregion.size() > 0) {
				wrnonzero = true;
				TreeSet<Integer> p1reacheswr = p1reachesWR(game, remaining, p1winningregion);
				remaining.removeAll(p1winningregion);
				remaining.removeAll(p1reacheswr);
			} else if (remaining.size() > 0) {
				for (Integer from : remaining)
					if (game.states.get(from).player == 2) {
						assert(!allowed.containsKey(from));
						if (game.states.get(from).rank > 0) { 
							for (Integer into : game.transitions.get(from))
								if (remaining.contains(into) && game.states.get(into).rank != -1 &&
									game.states.get(into).rank < game.states.get(from).rank) {
									if (!allowed.containsKey(from))
										allowed.put(from, new TreeSet<Integer>());
									allowed.get(from).add(into);
								}
						}
						if (game.states.get(from).rank == 0) { 
							for (Integer into : game.transitions.get(from))
								if (remaining.contains(into) && game.states.get(into).rank != -1) {
									if (!allowed.containsKey(from))
										allowed.put(from, new TreeSet<Integer>());
									allowed.get(from).add(into);
								}					
						}
						assert(allowed.containsKey(from));
					}
			}
		} while (wrnonzero && remaining.size() > 0);
		return remaining;
	}
private static TreeSet < Integer > solveOneTwoSubgame ( Game game , TreeSet < Integer > states , TreeMap < Integer , TreeSet < Integer > > allowed ) { if ( states . size ( ) == 0 ) return new TreeSet < Integer > ( ) ; TreeSet < Integer > remaining = new TreeSet < Integer > ( states ) ; Boolean wrnonzero ; do { wrnonzero = false ; TreeSet < Integer > targets = new TreeSet < Integer > ( ) ; for ( Integer key : remaining ) if ( game . states . get ( key ) . parity == 1 ) targets . add ( key ) ; Ranks . subgame ( game , remaining , targets , 2 ) ; TreeSet < Integer > p1winningregion = new TreeSet < Integer > ( ) ; for ( Integer key : remaining ) if ( game . states . get ( key ) . rank == - 1 ) p1winningregion . add ( key ) ; if ( p1winningregion . size ( ) > 0 ) { wrnonzero = true ; TreeSet < Integer > p1reacheswr = p1reachesWR ( game , remaining , p1winningregion ) ; remaining . removeAll ( p1winningregion ) ; remaining . removeAll ( p1reacheswr ) ; } else if ( remaining . size ( ) > 0 ) { for ( Integer from : remaining ) if ( game . states . get ( from ) . player == 2 ) { assert ( ! allowed . containsKey ( from ) ) ; if ( game . states . get ( from ) . rank > 0 ) { for ( Integer into : game . transitions . get ( from ) ) if ( remaining . contains ( into ) && game . states . get ( into ) . rank != - 1 && game . states . get ( into ) . rank < game . states . get ( from ) . rank ) { if ( ! allowed . containsKey ( from ) ) allowed . put ( from , new TreeSet < Integer > ( ) ) ; allowed . get ( from ) . add ( into ) ; } } if ( game . states . get ( from ) . rank == 0 ) { for ( Integer into : game . transitions . get ( from ) ) if ( remaining . contains ( into ) && game . states . get ( into ) . rank != - 1 ) { if ( ! allowed . containsKey ( from ) ) allowed . put ( from , new TreeSet < Integer > ( ) ) ; allowed . get ( from ) . add ( into ) ; } } assert ( allowed . containsKey ( from ) ) ; } } } while ( wrnonzero && remaining . size ( ) > 0 ) ; return remaining ; }
Solves a 1/2 subgame
 @param game          The entire game
 @param states        State space of the 1/2 subgame
 @param allowed       Update P2 strategy here
 @return                      Player 2 winning region
Solves a 1 / 2 subgame @param game The entire game @param states State space of the 1 / 2 subgame @param allowed Update P2 strategy here @return Player 2 winning region
// From some states P2 can't ensure reaching parity1 state // Find P1 attractor to these states // Don't update the P2 strategy // From all states P2 can ensure reaching parity1 state // Add the behavior of P2 in this region into the strategy // nonzero, noninfinity // zero