src/creator/Aiger.java
public static Pair<Game,Integer> create(String filename) {
		int lowerbound = 0;   // this size is not enough
		int upperboundTT = Integer.MAX_VALUE; // this size is enough
		int upperboundFF = Integer.MAX_VALUE; // gave up, state space too big
		
		int testsize = 4;
		boolean stop = false;
		Game game = null;
		while (!stop) {
			System.out.print("Distance limit = "+testsize+"... ");
			Pair<Game, Boolean> result = create(game, filename, testsize);
			if (result == null) return null;
			
			if (!result.second()) { // state space too big
				stop = true;
				upperboundFF = testsize;
				System.out.println("state space too big.");
				break;
			}
			
			game = result.first();
			Ranks.entire(game, 1);
			
			if (game.states.get(game.initialState).rank == -1) {
				// Winning for P2 even with the distance constraint
				stop = true;
				upperboundTT = testsize;
				System.out.println("winning for Player 2!");
			} else {
				lowerbound = testsize;
				System.out.println("distance too small.");
				testsize *= 2;
			}
		}
		
		game = null;
		System.gc();
		
		assert(Math.min(upperboundTT, upperboundFF) < Integer.MAX_VALUE);
		assert((lowerbound == 0 && Math.min(upperboundTT, upperboundFF) == 4)
				|| 2 * lowerbound == Math.min(upperboundTT, upperboundFF));
		
		int change = Math.min(upperboundTT, upperboundFF) - lowerbound;
		assert((lowerbound == 0 && change == 4) || change == lowerbound);
		assert(change % 2 == 0);
		change /= 2;
		testsize = Math.min(upperboundTT, upperboundFF);
		testsize -= change;
		assert(testsize - lowerbound == Math.min(upperboundTT, upperboundFF) - testsize);
		
		while (lowerbound + 1 != Math.min(upperboundTT, upperboundFF)) {
			System.out.print("Distance limit = "+testsize+"... ");
			Pair<Game, Boolean> result = create(game, filename, testsize);
			if (result == null) return null;
			
			if (!result.second()) { // state space too big
				assert(upperboundTT == Integer.MAX_VALUE);
				upperboundFF = testsize;
				System.out.println("state space too big.");
				
				game = null;
				System.gc();
				
				if (change == 1) {
					assert(lowerbound + 1 == upperboundFF);
					continue;
				}
				
				assert(change % 2 == 0);
				change /= 2;
				testsize -= change;
				assert(testsize - lowerbound == upperboundFF - testsize);
				
				continue;
			}
			
			game = result.first();
			Ranks.entire(game, 1);
			
			if (game.states.get(game.initialState).rank == -1) {
				// Winning for P2 even with the distance constraint
				upperboundTT = testsize;
				System.out.println("winning for Player 2!");
				
				game = null;
				System.gc();				
				
				if (change == 1) {
					assert(lowerbound + 1 == upperboundTT);
					continue;
				}
				
				assert(change % 2 == 0);
				change /= 2;
				testsize -= change;
				assert(testsize - lowerbound == upperboundTT - testsize);
				
			} else {
				lowerbound = testsize;
				System.out.println("distance too small.");
				
				// dont garbage collect, keep the game for reuse
				
				if (change == 1) {
					assert(lowerbound + 1 == Math.min(upperboundTT, upperboundFF));
					continue;
				}
				
				assert(change % 2 == 0);
				change /= 2;
				testsize += change;
				assert(testsize - lowerbound == Math.min(upperboundTT, upperboundFF) - testsize);
			}
		}
		
		game = null;
		System.gc();
		
		if (upperboundTT == Integer.MAX_VALUE) {
			System.out.println("FAIL: Didn't find any winning strategy.");
			return new Pair<Game, Integer>(null, -1);
		}
		
		System.out.println("SUCCESS: The smallest winning strategy is for distance "+upperboundTT+".");
		Pair<Game, Boolean> result = create(game, filename, upperboundTT);
		assert(result.second());
		
		return new Pair<Game, Integer>(result.first(), upperboundTT);
	}
/** Creates a game from the AIGER file benchmarks/aiger/filename.aag
	 * @param filename	Name of the AIGER file
	 * @return 			(Game, Distance restriction)
	 * */
Creates a game from the AIGER file benchmarks/aiger/filename.aag
@param filename      Name of the AIGER file
@return                      (Game, Distance restriction)
Creates a game from the AIGER file benchmarks / aiger / filename . aag @param filename Name of the AIGER file @return ( Game Distance restriction )
public static Pair<Game,Integer> create(String filename) {
		int lowerbound = 0;   
		int upperboundTT = Integer.MAX_VALUE; 
		int upperboundFF = Integer.MAX_VALUE; 
		int testsize = 4;
		boolean stop = false;
		Game game = null;
		while (!stop) {
			System.out.print("Distance limit = "+testsize+"... ");
			Pair<Game, Boolean> result = create(game, filename, testsize);
			if (result == null) return null;
			if (!result.second()) { 
				stop = true;
				upperboundFF = testsize;
				System.out.println("state space too big.");
				break;
			}
			game = result.first();
			Ranks.entire(game, 1);
			if (game.states.get(game.initialState).rank == -1) {
				stop = true;
				upperboundTT = testsize;
				System.out.println("winning for Player 2!");
			} else {
				lowerbound = testsize;
				System.out.println("distance too small.");
				testsize *= 2;
			}
		}
		game = null;
		System.gc();
		assert(Math.min(upperboundTT, upperboundFF) < Integer.MAX_VALUE);
		assert((lowerbound == 0 && Math.min(upperboundTT, upperboundFF) == 4)
				|| 2 * lowerbound == Math.min(upperboundTT, upperboundFF));
		int change = Math.min(upperboundTT, upperboundFF) - lowerbound;
		assert((lowerbound == 0 && change == 4) || change == lowerbound);
		assert(change % 2 == 0);
		change /= 2;
		testsize = Math.min(upperboundTT, upperboundFF);
		testsize -= change;
		assert(testsize - lowerbound == Math.min(upperboundTT, upperboundFF) - testsize);
		while (lowerbound + 1 != Math.min(upperboundTT, upperboundFF)) {
			System.out.print("Distance limit = "+testsize+"... ");
			Pair<Game, Boolean> result = create(game, filename, testsize);
			if (result == null) return null;
			if (!result.second()) { 
				assert(upperboundTT == Integer.MAX_VALUE);
				upperboundFF = testsize;
				System.out.println("state space too big.");
				game = null;
				System.gc();
				if (change == 1) {
					assert(lowerbound + 1 == upperboundFF);
					continue;
				}
				assert(change % 2 == 0);
				change /= 2;
				testsize -= change;
				assert(testsize - lowerbound == upperboundFF - testsize);
				continue;
			}
			game = result.first();
			Ranks.entire(game, 1);
			if (game.states.get(game.initialState).rank == -1) {
				upperboundTT = testsize;
				System.out.println("winning for Player 2!");
				game = null;
				System.gc();				
				if (change == 1) {
					assert(lowerbound + 1 == upperboundTT);
					continue;
				}
				assert(change % 2 == 0);
				change /= 2;
				testsize -= change;
				assert(testsize - lowerbound == upperboundTT - testsize);
			} else {
				lowerbound = testsize;
				System.out.println("distance too small.");
				if (change == 1) {
					assert(lowerbound + 1 == Math.min(upperboundTT, upperboundFF));
					continue;
				}
				assert(change % 2 == 0);
				change /= 2;
				testsize += change;
				assert(testsize - lowerbound == Math.min(upperboundTT, upperboundFF) - testsize);
			}
		}
		game = null;
		System.gc();
		if (upperboundTT == Integer.MAX_VALUE) {
			System.out.println("FAIL: Didn't find any winning strategy.");
			return new Pair<Game, Integer>(null, -1);
		}
		System.out.println("SUCCESS: The smallest winning strategy is for distance "+upperboundTT+".");
		Pair<Game, Boolean> result = create(game, filename, upperboundTT);
		assert(result.second());
		return new Pair<Game, Integer>(result.first(), upperboundTT);
	}
public static Pair < Game , Integer > create ( String filename ) { int lowerbound = 0 ; int upperboundTT = Integer . MAX_VALUE ; int upperboundFF = Integer . MAX_VALUE ; int testsize = 4 ; boolean stop = false ; Game game = null ; while ( ! stop ) { System . out . print ( "Distance limit = " + testsize + "... " ) ; Pair < Game , Boolean > result = create ( game , filename , testsize ) ; if ( result == null ) return null ; if ( ! result . second ( ) ) { stop = true ; upperboundFF = testsize ; System . out . println ( "state space too big." ) ; break ; } game = result . first ( ) ; Ranks . entire ( game , 1 ) ; if ( game . states . get ( game . initialState ) . rank == - 1 ) { stop = true ; upperboundTT = testsize ; System . out . println ( "winning for Player 2!" ) ; } else { lowerbound = testsize ; System . out . println ( "distance too small." ) ; testsize *= 2 ; } } game = null ; System . gc ( ) ; assert ( Math . min ( upperboundTT , upperboundFF ) < Integer . MAX_VALUE ) ; assert ( ( lowerbound == 0 && Math . min ( upperboundTT , upperboundFF ) == 4 ) || 2 * lowerbound == Math . min ( upperboundTT , upperboundFF ) ) ; int change = Math . min ( upperboundTT , upperboundFF ) - lowerbound ; assert ( ( lowerbound == 0 && change == 4 ) || change == lowerbound ) ; assert ( change % 2 == 0 ) ; change /= 2 ; testsize = Math . min ( upperboundTT , upperboundFF ) ; testsize -= change ; assert ( testsize - lowerbound == Math . min ( upperboundTT , upperboundFF ) - testsize ) ; while ( lowerbound + 1 != Math . min ( upperboundTT , upperboundFF ) ) { System . out . print ( "Distance limit = " + testsize + "... " ) ; Pair < Game , Boolean > result = create ( game , filename , testsize ) ; if ( result == null ) return null ; if ( ! result . second ( ) ) { assert ( upperboundTT == Integer . MAX_VALUE ) ; upperboundFF = testsize ; System . out . println ( "state space too big." ) ; game = null ; System . gc ( ) ; if ( change == 1 ) { assert ( lowerbound + 1 == upperboundFF ) ; continue ; } assert ( change % 2 == 0 ) ; change /= 2 ; testsize -= change ; assert ( testsize - lowerbound == upperboundFF - testsize ) ; continue ; } game = result . first ( ) ; Ranks . entire ( game , 1 ) ; if ( game . states . get ( game . initialState ) . rank == - 1 ) { upperboundTT = testsize ; System . out . println ( "winning for Player 2!" ) ; game = null ; System . gc ( ) ; if ( change == 1 ) { assert ( lowerbound + 1 == upperboundTT ) ; continue ; } assert ( change % 2 == 0 ) ; change /= 2 ; testsize -= change ; assert ( testsize - lowerbound == upperboundTT - testsize ) ; } else { lowerbound = testsize ; System . out . println ( "distance too small." ) ; if ( change == 1 ) { assert ( lowerbound + 1 == Math . min ( upperboundTT , upperboundFF ) ) ; continue ; } assert ( change % 2 == 0 ) ; change /= 2 ; testsize += change ; assert ( testsize - lowerbound == Math . min ( upperboundTT , upperboundFF ) - testsize ) ; } } game = null ; System . gc ( ) ; if ( upperboundTT == Integer . MAX_VALUE ) { System . out . println ( "FAIL: Didn't find any winning strategy." ) ; return new Pair < Game , Integer > ( null , - 1 ) ; } System . out . println ( "SUCCESS: The smallest winning strategy is for distance " + upperboundTT + "." ) ; Pair < Game , Boolean > result = create ( game , filename , upperboundTT ) ; assert ( result . second ( ) ) ; return new Pair < Game , Integer > ( result . first ( ) , upperboundTT ) ; }
Creates a game from the AIGER file benchmarks/aiger/filename.aag
 @param filename      Name of the AIGER file
 @return                      (Game, Distance restriction)
Creates a game from the AIGER file benchmarks / aiger / filename . aag @param filename Name of the AIGER file @return ( Game Distance restriction )
// this size is not enough // this size is enough // gave up, state space too big // state space too big // Winning for P2 even with the distance constraint // state space too big // Winning for P2 even with the distance constraint // dont garbage collect, keep the game for reuse