	public Set<IMove> getPossibleMovesFrom(int square) {
		int type = PieceHelper.pieceType(getFromBoard(square));
		int opp_color = getOpponentsColor();
		List<Integer> squares;
		Set<IMove> moves = new HashSet<IMove>();
		Move move;
		if (type == PieceHelper.BISHOP || type == PieceHelper.QUEEN
				|| type == PieceHelper.ROOK) {
			for (Direction direction : Direction.values()) {
				if (((direction == Direction.NORTH
						|| direction == Direction.EAST
						|| direction == Direction.SOUTH || direction == Direction.WEST) && type == PieceHelper.BISHOP)
						|| ((direction == Direction.NORTHWEST
								|| direction == Direction.NORTHEAST
								|| direction == Direction.SOUTHEAST || direction == Direction.SOUTHWEST) && type == PieceHelper.ROOK)) {
					continue;
				} else {
					squares = SquareHelper.getAllSquaresInDirection(square,
							direction);
					for (Integer new_square : squares) {
						if (getFromBoard(new_square) == 0
								|| PieceHelper
										.pieceColor(getFromBoard(new_square)) == opp_color) {
							move = new Move(square, new_square);
							moves.add(move);
							if (getFromBoard(new_square) != 0
									&& PieceHelper
											.pieceColor(getFromBoard(new_square)) == opp_color)
								break;
						} else
							break;
					}
				}
			}
		}
		if (type == PieceHelper.PAWN) {
			if ((SquareHelper.getRow(square) == 2 && active_color == PieceHelper.WHITE)
					|| (SquareHelper.getRow(square) == 7 && active_color == PieceHelper.BLACK)) {
				if (getFromBoard(square
						+ Direction.pawnDirection(active_color).offset) == 0) {
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset);
					moves.add(move);
					if (getFromBoard(square + 2
							* Direction.pawnDirection(active_color).offset) == 0) {
						move = new Move(square, square + 2
								* Direction.pawnDirection(active_color).offset);
						moves.add(move);
					}
				}
				Set<Direction> pawn_capturing_directions = Direction
						.pawnCapturingDirections(active_color);
				for (Direction direction : pawn_capturing_directions) {
					if (getFromBoard(square + direction.offset) != 0
							&& PieceHelper.pieceColor(getFromBoard(square
									+ direction.offset)) == getOpponentsColor()) {
						move = new Move(square, square + direction.offset);
						moves.add(move);
					}
				}
			}
			else if ((SquareHelper.getRow(square) == 7 && active_color == PieceHelper.WHITE)
					|| (SquareHelper.getRow(square) == 2 && active_color == PieceHelper.BLACK)) {
				if (getFromBoard(square
						+ Direction.pawnDirection(active_color).offset) == 0) {
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset,
							PieceHelper.QUEEN);
					moves.add(move);
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset,
							PieceHelper.KNIGHT);
					moves.add(move);
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset,
							PieceHelper.ROOK);
					moves.add(move);
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset,
							PieceHelper.BISHOP);
					moves.add(move);
				}
				Set<Direction> pawn_capturing_directions = Direction
						.pawnCapturingDirections(active_color);
				for (Direction direction : pawn_capturing_directions) {
					if (getFromBoard(square + direction.offset) != 0
							&& PieceHelper.pieceColor(getFromBoard(square
									+ direction.offset)) == getOpponentsColor()) {
						move = new Move(square, square + direction.offset,
								PieceHelper.QUEEN);
						moves.add(move);
						move = new Move(square, square + direction.offset,
								PieceHelper.KNIGHT);
						moves.add(move);
					}
				}
			}
			else {
				if (getFromBoard(square
						+ Direction.pawnDirection(active_color).offset) == 0) {
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset);
					moves.add(move);
				}
				Set<Direction> pawn_capturing_directions = Direction
						.pawnCapturingDirections(active_color);
				for (Direction direction : pawn_capturing_directions) {
					if ((getFromBoard(square + direction.offset) != 0 && PieceHelper
							.pieceColor(getFromBoard(square + direction.offset)) == getOpponentsColor())
							|| getFromBoard(square + direction.offset) == getEnPassant()) {
						move = new Move(square, square + direction.offset);
						moves.add(move);
					}
				}
			}
		}

	public Set<IMove> getPossibleMovesFrom(int square) {
		int type = PieceHelper.pieceType(getFromBoard(square));
		int opp_color = getOpponentsColor();
		List<Integer> squares;
		Set<IMove> moves = new HashSet<IMove>();
		Move move;
		if (type == PieceHelper.BISHOP || type == PieceHelper.QUEEN
				|| type == PieceHelper.ROOK) {
			for (Direction direction : Direction.values()) {
				if (((direction == Direction.NORTH
						|| direction == Direction.EAST
						|| direction == Direction.SOUTH || direction == Direction.WEST) && type == PieceHelper.BISHOP)
						|| ((direction == Direction.NORTHWEST
								|| direction == Direction.NORTHEAST
								|| direction == Direction.SOUTHEAST || direction == Direction.SOUTHWEST) && type == PieceHelper.ROOK)) {
					continue;
				} else {
					squares = SquareHelper.getAllSquaresInDirection(square,
							direction);
					for (Integer new_square : squares) {
						if (getFromBoard(new_square) == 0
								|| PieceHelper
										.pieceColor(getFromBoard(new_square)) == opp_color) {
							move = new Move(square, new_square);
							moves.add(move);
							if (getFromBoard(new_square) != 0
									&& PieceHelper
											.pieceColor(getFromBoard(new_square)) == opp_color)
								break;
						} else
							break;
					}
				}
			}
		}
		if (type == PieceHelper.PAWN) {
			if ((SquareHelper.getRow(square) == 2 && active_color == PieceHelper.WHITE)
					|| (SquareHelper.getRow(square) == 7 && active_color == PieceHelper.BLACK)) {
				if (getFromBoard(square
						+ Direction.pawnDirection(active_color).offset) == 0) {
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset);
					moves.add(move);
					if (getFromBoard(square + 2
							* Direction.pawnDirection(active_color).offset) == 0) {
						move = new Move(square, square + 2
								* Direction.pawnDirection(active_color).offset);
						moves.add(move);
					}
				}
				Set<Direction> pawn_capturing_directions = Direction
						.pawnCapturingDirections(active_color);
				for (Direction direction : pawn_capturing_directions) {
					if (getFromBoard(square + direction.offset) != 0
							&& PieceHelper.pieceColor(getFromBoard(square
									+ direction.offset)) == getOpponentsColor()) {
						move = new Move(square, square + direction.offset);
						moves.add(move);
					}
				}
			}
			else if ((SquareHelper.getRow(square) == 7 && active_color == PieceHelper.WHITE)
					|| (SquareHelper.getRow(square) == 2 && active_color == PieceHelper.BLACK)) {
				if (getFromBoard(square
						+ Direction.pawnDirection(active_color).offset) == 0) {
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset,
							PieceHelper.QUEEN);
					moves.add(move);
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset,
							PieceHelper.KNIGHT);
					moves.add(move);
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset,
							PieceHelper.ROOK);
					moves.add(move);
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset,
							PieceHelper.BISHOP);
					moves.add(move);
				}
				Set<Direction> pawn_capturing_directions = Direction
						.pawnCapturingDirections(active_color);
				for (Direction direction : pawn_capturing_directions) {
					if (getFromBoard(square + direction.offset) != 0
							&& PieceHelper.pieceColor(getFromBoard(square
									+ direction.offset)) == getOpponentsColor()) {
						move = new Move(square, square + direction.offset,
								PieceHelper.QUEEN);
						moves.add(move);
						move = new Move(square, square + direction.offset,
								PieceHelper.KNIGHT);
						moves.add(move);
					}
				}
			}
			else {
				if (getFromBoard(square
						+ Direction.pawnDirection(active_color).offset) == 0) {
					move = new Move(square, square
							+ Direction.pawnDirection(active_color).offset);
					moves.add(move);
				}
				Set<Direction> pawn_capturing_directions = Direction
						.pawnCapturingDirections(active_color);
				for (Direction direction : pawn_capturing_directions) {
					if ((getFromBoard(square + direction.offset) != 0 && PieceHelper
							.pieceColor(getFromBoard(square + direction.offset)) == getOpponentsColor())
							|| square + direction.offset == getEnPassant()) {
						move = new Move(square, square + direction.offset);
						moves.add(move);
					}
				}
			}
		}
