public PatternDatabaseGenerator(final int numOfTiles, final long boardConfig,
			final byte dummyTile, final String filename) {
		this.numOfTiles = Node.numOfTiles = numOfTiles;
		this.numOfTilesMinusOne = numOfTiles - 1;
		this.dimension = Node.dimension = (int) Math.sqrt(numOfTiles);
		DataOutputStream dos = null;
		if (filename != null) {
			try {
				dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filename)));
			} catch (final FileNotFoundException fnfe) {
				System.err.println("Error: Cannot open file '" + filename + "' for output.");
				System.exit(1);
			}
		}
		if (this.numOfTilesMinusOne == 15) {
			generateFifteenPuzzleDB(dummyTile, boardConfig);
			outputFifteenPuzzleData(filename, dos);
		} else {
			generateEightPuzzleDB(boardConfig);
			outputEightPuzzleData(filename, dos);
		}
	}