src/strategy/Reachability.java
public static Strategy classical(Game game, GameInfo gameinfo) {
		assert(game != null);
		Ranks.entire(game, 1);
		if (game.states.get(game.initialState).rank < 1) // zero or -1 (infinity)
			return null;
		
		Strategy result = new Strategy(1,'r');
		
        LinkedList<Integer> queue = new LinkedList<Integer>();
		TreeSet<Integer> flag = new TreeSet<Integer>();
		queue.add(game.initialState);
		flag.add(game.initialState);
		
		TreeMap<Integer,AtomicInteger> used = new TreeMap<Integer,AtomicInteger>();
		
		while (queue.size() > 0) {
			Integer from = queue.remove();
			if (game.states.get(from).player == 1) { // restricted by the strategy
				assert(game.states.get(from).rank > 0);
				int choicefrom = -1;
				int valuefrom = -1;
				int succfrom = -1;
				int choicenew = -1;
				int valuenew = -1;
				int succnew = -1;

				for (int i=0; i<Util.bitpower(game.varActionP1no()); i++) {
					int into = game.successor(gameinfo, from, i, 2);
					if (game.states.get(into).rank < game.states.get(from).rank && game.states.get(into).rank != -1) {
						// We can consider this label
						if (used.containsKey(i)) {
							if (used.get(i).intValue() > valuefrom) {
								choicefrom = i;
								valuefrom = used.get(i).intValue();
								succfrom = into;
								choicenew = -1;
								valuenew = -1;
								succnew = -1;
							}
						}
						else if (choicefrom == -1 && Util.numberOfOnes(i) > valuenew) {
								choicenew = i;
								valuenew = Util.numberOfOnes(i);
								succnew = into;
						}
					}
				}
				
				if (choicefrom != -1) {
					assert(valuefrom > -1 && succfrom > -1);
					used.get(choicefrom).incrementAndGet();
					result.addBitv(game, from, choicefrom, true);
					
					for (int i=0; i<Util.bitpower(game.varActionP1no()); i++)
						if (i != choicefrom)
							result.addBitv(game, from, i, false);
					
					if (!flag.contains(succfrom) && game.states.get(succfrom).rank != 0) {
						queue.add(succfrom);
						flag.add(succfrom);							
					}
					
				} else {
					assert(choicenew > -1 && valuenew > -1 && succnew > -1);
					used.put(choicenew, new AtomicInteger(1));
					result.addBitv(game, from, choicenew, true);
					
					for (int i=0; i<Util.bitpower(game.varActionP1no()); i++)
						if (i != choicenew)
							result.addBitv(game, from, i, false);
					
					if (!flag.contains(succnew) && game.states.get(succnew).rank != 0) {
						queue.add(succnew);
						flag.add(succnew);
					}
				}
				
			} else { // the opponent is allowed to move anywhere
				for (Integer into : game.transitions.get(from))
					if (!flag.contains(into) && game.states.get(into).rank != 0) {
						assert(game.states.get(into).rank != -1);
						queue.add(into);
						flag.add(into);
					}
			}
		}
		
		return result;
	}
/**
	 * Computes classical (one action per state) reachability strategy for player 1
	 * @param game		Compute for this game
	 * @param gameinfo  Info about the game
	 * @return          The strategy
	 */
Computes classical (one action per state) reachability strategy for player 1
@param game          Compute for this game
@param gameinfo  Info about the game
@return          The strategy
Computes classical ( one action per state ) reachability strategy for player 1 @param game Compute for this game @param gameinfo Info about the game @return The strategy
public static Strategy classical(Game game, GameInfo gameinfo) {
		assert(game != null);
		Ranks.entire(game, 1);
		if (game.states.get(game.initialState).rank < 1) 
			return null;
		Strategy result = new Strategy(1,'r');
        LinkedList<Integer> queue = new LinkedList<Integer>();
		TreeSet<Integer> flag = new TreeSet<Integer>();
		queue.add(game.initialState);
		flag.add(game.initialState);
		TreeMap<Integer,AtomicInteger> used = new TreeMap<Integer,AtomicInteger>();
		while (queue.size() > 0) {
			Integer from = queue.remove();
			if (game.states.get(from).player == 1) { 
				assert(game.states.get(from).rank > 0);
				int choicefrom = -1;
				int valuefrom = -1;
				int succfrom = -1;
				int choicenew = -1;
				int valuenew = -1;
				int succnew = -1;
				for (int i=0; i<Util.bitpower(game.varActionP1no()); i++) {
					int into = game.successor(gameinfo, from, i, 2);
					if (game.states.get(into).rank < game.states.get(from).rank && game.states.get(into).rank != -1) {
						if (used.containsKey(i)) {
							if (used.get(i).intValue() > valuefrom) {
								choicefrom = i;
								valuefrom = used.get(i).intValue();
								succfrom = into;
								choicenew = -1;
								valuenew = -1;
								succnew = -1;
							}
						}
						else if (choicefrom == -1 && Util.numberOfOnes(i) > valuenew) {
								choicenew = i;
								valuenew = Util.numberOfOnes(i);
								succnew = into;
						}
					}
				}
				if (choicefrom != -1) {
					assert(valuefrom > -1 && succfrom > -1);
					used.get(choicefrom).incrementAndGet();
					result.addBitv(game, from, choicefrom, true);
					for (int i=0; i<Util.bitpower(game.varActionP1no()); i++)
						if (i != choicefrom)
							result.addBitv(game, from, i, false);
					if (!flag.contains(succfrom) && game.states.get(succfrom).rank != 0) {
						queue.add(succfrom);
						flag.add(succfrom);							
					}
				} else {
					assert(choicenew > -1 && valuenew > -1 && succnew > -1);
					used.put(choicenew, new AtomicInteger(1));
					result.addBitv(game, from, choicenew, true);
					for (int i=0; i<Util.bitpower(game.varActionP1no()); i++)
						if (i != choicenew)
							result.addBitv(game, from, i, false);
					if (!flag.contains(succnew) && game.states.get(succnew).rank != 0) {
						queue.add(succnew);
						flag.add(succnew);
					}
				}
			} else { 
				for (Integer into : game.transitions.get(from))
					if (!flag.contains(into) && game.states.get(into).rank != 0) {
						assert(game.states.get(into).rank != -1);
						queue.add(into);
						flag.add(into);
					}
			}
		}
		return result;
	}
public static Strategy classical ( Game game , GameInfo gameinfo ) { assert ( game != null ) ; Ranks . entire ( game , 1 ) ; if ( game . states . get ( game . initialState ) . rank < 1 ) return null ; Strategy result = new Strategy ( 1 , 'r' ) ; LinkedList < Integer > queue = new LinkedList < Integer > ( ) ; TreeSet < Integer > flag = new TreeSet < Integer > ( ) ; queue . add ( game . initialState ) ; flag . add ( game . initialState ) ; TreeMap < Integer , AtomicInteger > used = new TreeMap < Integer , AtomicInteger > ( ) ; while ( queue . size ( ) > 0 ) { Integer from = queue . remove ( ) ; if ( game . states . get ( from ) . player == 1 ) { assert ( game . states . get ( from ) . rank > 0 ) ; int choicefrom = - 1 ; int valuefrom = - 1 ; int succfrom = - 1 ; int choicenew = - 1 ; int valuenew = - 1 ; int succnew = - 1 ; for ( int i = 0 ; i < Util . bitpower ( game . varActionP1no ( ) ) ; i ++ ) { int into = game . successor ( gameinfo , from , i , 2 ) ; if ( game . states . get ( into ) . rank < game . states . get ( from ) . rank && game . states . get ( into ) . rank != - 1 ) { if ( used . containsKey ( i ) ) { if ( used . get ( i ) . intValue ( ) > valuefrom ) { choicefrom = i ; valuefrom = used . get ( i ) . intValue ( ) ; succfrom = into ; choicenew = - 1 ; valuenew = - 1 ; succnew = - 1 ; } } else if ( choicefrom == - 1 && Util . numberOfOnes ( i ) > valuenew ) { choicenew = i ; valuenew = Util . numberOfOnes ( i ) ; succnew = into ; } } } if ( choicefrom != - 1 ) { assert ( valuefrom > - 1 && succfrom > - 1 ) ; used . get ( choicefrom ) . incrementAndGet ( ) ; result . addBitv ( game , from , choicefrom , true ) ; for ( int i = 0 ; i < Util . bitpower ( game . varActionP1no ( ) ) ; i ++ ) if ( i != choicefrom ) result . addBitv ( game , from , i , false ) ; if ( ! flag . contains ( succfrom ) && game . states . get ( succfrom ) . rank != 0 ) { queue . add ( succfrom ) ; flag . add ( succfrom ) ; } } else { assert ( choicenew > - 1 && valuenew > - 1 && succnew > - 1 ) ; used . put ( choicenew , new AtomicInteger ( 1 ) ) ; result . addBitv ( game , from , choicenew , true ) ; for ( int i = 0 ; i < Util . bitpower ( game . varActionP1no ( ) ) ; i ++ ) if ( i != choicenew ) result . addBitv ( game , from , i , false ) ; if ( ! flag . contains ( succnew ) && game . states . get ( succnew ) . rank != 0 ) { queue . add ( succnew ) ; flag . add ( succnew ) ; } } } else { for ( Integer into : game . transitions . get ( from ) ) if ( ! flag . contains ( into ) && game . states . get ( into ) . rank != 0 ) { assert ( game . states . get ( into ) . rank != - 1 ) ; queue . add ( into ) ; flag . add ( into ) ; } } } return result ; }
Computes classical (one action per state) reachability strategy for player 1
 @param game          Compute for this game
 @param gameinfo  Info about the game
 @return          The strategy
Computes classical ( one action per state ) reachability strategy for player 1 @param game Compute for this game @param gameinfo Info about the game @return The strategy
// zero or -1 (infinity) // restricted by the strategy // We can consider this label // the opponent is allowed to move anywhere