// Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
// 
// 	private static final int MAX_MOVES = 256;
// 
// 	final T[] entries;
// 	int size = 0;
// 
// 	static final class MoveVariation {
// 
// 		final int[] moves = new int[MAX_PLY];
// 		int size = 0;
// 	}
// 
// 	static class MoveEntry {
// 
// 		int move = NOMOVE;
// 		int value = NOVALUE;
// 	}
// 
// 	static final class RootEntry extends MoveEntry {
// 
// 		final MoveVariation pv = new MoveVariation();
// 	}
// 
// 	MoveList(Class<T> clazz) {
// 		@SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// 		this.entries = entries;
// 		try {
// 			for (int i = 0; i < entries.length; i++) {
// 				entries[i] = clazz.getDeclaredConstructor().newInstance();
// 			}
// 		} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// 			throw new IllegalStateException(e);
// 		}
// 	}
// 
// 	/**
// 	 * Sorts the move list using a stable insertion sort.
// 	 */
// 	void sort() {
// 		for (int i = 1; i < size; i++) {
// 			T entry = entries[i];
// 
// 			int j = i;
// 			while ((j > 0) && (entries[j - 1].value < entry.value)) {
// 				entries[j] = entries[j - 1];
// 				j--;
// 			}
// 
// 			entries[j] = entry;
// 		}
// 	}
// 
// 	/**
// 	 * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// 	 */
// 	void rateFromMVVLVA() {
// 		for (int i = 0; i < size; i++) {
// 			int move = entries[i].move;
// 			int value = 0;
// 
// 			int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// 			value += KING_VALUE / piecetypeValue;
// 
// 			int target = Move.getTargetPiece(move);
// 			if (Piece.isValid(target)) {
// 				value += 10 * PieceType.getValue(Piece.getType(target));
// 			}
// 
// 			entries[i].value = value;
// 		}
// 	}
// }
// 
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// 	switch (color) {
// 		case WHITE:
// 			return BLACK;
// 		case BLACK:
// 			return WHITE;
// 		default:
// 			throw new IllegalArgumentException();
// 	}
// }
// 
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// 		| (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// 		| (NOSQUARE << TARGET_SQUARE_SHIFT)
// 		| (NOPIECE << ORIGIN_PIECE_SHIFT)
// 		| (NOPIECE << TARGET_PIECE_SHIFT)
// 		| (NOPIECETYPE << PROMOTION_SHIFT);
// 
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
// 
// 	public static final int INFINITE = 200000;
// 	public static final int CHECKMATE = 100000;
// 	public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// 	public static final int DRAW = 0;
// 
// 	public static final int NOVALUE = 300000;
// 
// 	private Value() {
// 	}
// 
// 	public static boolean isCheckmate(int value) {
// 		int absvalue = abs(value);
// 		return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// 	}
// }


import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
				return evaluation.evaluate(position);
			}

			// Check insufficient material, repetition and fifty move rule
			if (position.isRepetition() || position.hasInsufficientMaterial() || position.halfmoveClock >= 100) {
				return DRAW;
			}

			// Initialize
			int bestValue = -INFINITE;
			int searchedMoves = 0;
			boolean isCheck = position.isCheck();

			//### BEGIN Stand pat
			if (!isCheck) {
				bestValue = evaluation.evaluate(position);

				// Do we have a better value?
				if (bestValue > alpha) {
					alpha = bestValue;

					// Is the value higher than beta?
					if (bestValue >= beta) {
						// Cut-off
						return bestValue;
					}
				}
			}
			//### ENDOF Stand pat

// Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
// 
// 	private static final int MAX_MOVES = 256;
// 
// 	final T[] entries;
// 	int size = 0;
// 
// 	static final class MoveVariation {
// 
// 		final int[] moves = new int[MAX_PLY];
// 		int size = 0;
// 	}
// 
// 	static class MoveEntry {
// 
// 		int move = NOMOVE;
// 		int value = NOVALUE;
// 	}
// 
// 	static final class RootEntry extends MoveEntry {
// 
// 		final MoveVariation pv = new MoveVariation();
// 	}
// 
// 	MoveList(Class<T> clazz) {
// 		@SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// 		this.entries = entries;
// 		try {
// 			for (int i = 0; i < entries.length; i++) {
// 				entries[i] = clazz.getDeclaredConstructor().newInstance();
// 			}
// 		} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// 			throw new IllegalStateException(e);
// 		}
// 	}
// 
// 	/**
// 	 * Sorts the move list using a stable insertion sort.
// 	 */
// 	void sort() {
// 		for (int i = 1; i < size; i++) {
// 			T entry = entries[i];
// 
// 			int j = i;
// 			while ((j > 0) && (entries[j - 1].value < entry.value)) {
// 				entries[j] = entries[j - 1];
// 				j--;
// 			}
// 
// 			entries[j] = entry;
// 		}
// 	}
// 
// 	/**
// 	 * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// 	 */
// 	void rateFromMVVLVA() {
// 		for (int i = 0; i < size; i++) {
// 			int move = entries[i].move;
// 			int value = 0;
// 
// 			int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// 			value += KING_VALUE / piecetypeValue;
// 
// 			int target = Move.getTargetPiece(move);
// 			if (Piece.isValid(target)) {
// 				value += 10 * PieceType.getValue(Piece.getType(target));
// 			}
// 
// 			entries[i].value = value;
// 		}
// 	}
// }
// 
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// 	switch (color) {
// 		case WHITE:
// 			return BLACK;
// 		case BLACK:
// 			return WHITE;
// 		default:
// 			throw new IllegalArgumentException();
// 	}
// }
// 
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// 		| (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// 		| (NOSQUARE << TARGET_SQUARE_SHIFT)
// 		| (NOPIECE << ORIGIN_PIECE_SHIFT)
// 		| (NOPIECE << TARGET_PIECE_SHIFT)
// 		| (NOPIECETYPE << PROMOTION_SHIFT);
// 
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
// 
// 	public static final int INFINITE = 200000;
// 	public static final int CHECKMATE = 100000;
// 	public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// 	public static final int DRAW = 0;
// 
// 	public static final int NOVALUE = 300000;
// 
// 	private Value() {
// 	}
// 
// 	public static boolean isCheckmate(int value) {
// 		int absvalue = abs(value);
// 		return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// 	}
// }


// Path: src/main/java/com/fluxchess/pulse/Search.java
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;

				return evaluation.evaluate(position);
			}

			// Check insufficient material, repetition and fifty move rule
			if (position.isRepetition() || position.hasInsufficientMaterial() || position.halfmoveClock >= 100) {
				return DRAW;
			}

			// Initialize
			int bestValue = -INFINITE;
			int searchedMoves = 0;
			boolean isCheck = position.isCheck();

			//### BEGIN Stand pat
			if (!isCheck) {
				bestValue = evaluation.evaluate(position);

				// Do we have a better value?
				if (bestValue > alpha) {
					alpha = bestValue;

					// Is the value higher than beta?
					if (bestValue >= beta) {
						// Cut-off
						return bestValue;
					}
				}
			}
			//### ENDOF Stand pat

			MoveList<MoveEntry> moves = moveGenerators[ply].getMoves(position, depth, isCheck);