private static void makeMove(List<Piece> placedPieces,
			List<Piece> remainingPieces, boolean performAnalysis) {

		Piece curPiece = remainingPieces.get(0);
		boolean moreOptions = true;
		boolean testResult = false;

		while (moreOptions && !testResult) {

			testResult = testPiece(curPiece);
			if (!testResult) {
				moreOptions = shufflePiece(curPiece);

			} else if (performAnalysis) {

				// for debugging temporarily draw the piece being tested
				placedPieces.add(curPiece);
				myView.updatePieces(placedPieces);
				placedPieces.remove(curPiece);

				// check empty spaces surrounding the piece
				// do a quick (shallow) test of surrounding squares to see if
				// there is any immediate bad squares
				List<Piece> tempList = new ArrayList<Piece>(remainingPieces);
				tempList.remove(curPiece);
				placePiece(curPiece);
				List<Integer[]> resultsArray = getCountMapForSurroundingSquares(
						curPiece, tempList);
				removePiece(curPiece);

				if (resultsArray == null) {
					testResult = false;
					moreOptions = shufflePiece(curPiece);
				}
			}
		}

		// if we found a legitimate move
		if (testResult) {

			placePiece(curPiece);
			remainingPieces.remove(curPiece);
			placedPieces.add(curPiece);

			myView.updatePieces(placedPieces);

			// check for finish state
			checkEndOfGame(placedPieces, remainingPieces);

			// else we have reached a bad end and need to backtrack
		} else {

			if (!moreOptions) {
				// reset the start position of curPiece that we were unable to
				// place and add it back onto the remaining pieces
				resetPiece(curPiece);

				// remove the last placed piece from the board and then shuffle
				// it
				curPiece = placedPieces.get(placedPieces.size() - 1);
				removePiece(curPiece);
				shufflePiece(curPiece);

				placedPieces.remove(curPiece);
				remainingPieces.add(0, curPiece);
			}

			myView.updatePieces(placedPieces);
		}
	}