private State planIngredient(Domain domain, State startingState,
			IngredientRecipe ingredient, State currentState,
			List<RewardFunction> rewardFunctions,
			TerminalFunction recipeTerminalFunction,
			StateHashFactory hashFactory, StateConditionTest goalCondition,
			Heuristic heuristic, List<EpisodeAnalysis> episodes) {
		RewardFunction humanRewardFunction = rewardFunctions.get(0);
		RewardFunction robotRewardFunction = rewardFunctions.get(0);
		
		
		boolean finished = false;
		State endState = startingState;
		List<GroundedAction> fullActions = new ArrayList<GroundedAction>();
		List<Double> fullReward = new ArrayList<Double>();
		//boolean currentAgent = false;
		while (!finished) {
			
			//currentAgent = !currentAgent;
			//RewardFunction recipeRewardFunction = (currentAgent) ? humanRewardFunction : robotRewardFunction;
			
			State humanCurrentState = ExperimentHelper.setPrimaryAgent(currentState, "robot");
			State robotCurrentState = ExperimentHelper.setPrimaryAgent(currentState, "robot");
			
			/*State humanCurrentState = ExperimentHelper.setPrimaryAgent(currentState, "robot", ingredient);
			State robotCurrentState = ExperimentHelper.setPrimaryAgent(currentState, "robot", ingredient);*/
			
			AStar robotAgent = new AStar(domain, robotRewardFunction, goalCondition, hashFactory, heuristic);
			AStar humanAgent = new AStar(domain, humanRewardFunction, goalCondition, hashFactory, heuristic);
			robotAgent.planFromState(robotCurrentState);
			humanAgent.planFromState(humanCurrentState);
			
			Policy robotPolicy = new DDPlannerPolicy(robotAgent);
			Policy humanPolicy = new DDPlannerPolicy(humanAgent);
			
			EpisodeAnalysis robotEpisodes = 
					robotPolicy.evaluateBehavior(robotCurrentState, robotRewardFunction, recipeTerminalFunction);	
			EpisodeAnalysis humanEpisodes = 
					humanPolicy.evaluateBehavior(humanCurrentState, humanRewardFunction, recipeTerminalFunction);	
			
			if (robotEpisodes.actionSequence.size() <= 1 ||
					humanEpisodes.actionSequence.size() <= 1) {
				finished = true;
				continue;
			}
			GroundedAction robotAction = ExperimentHelper.getFirstRelavantAction(robotEpisodes.actionSequence, "robot");
			GroundedAction humanAction = ExperimentHelper.getFirstRelavantAction(humanEpisodes.actionSequence, "human");

			System.out.println("Robot tries action " + robotAction.toString());
			System.out.println("Human tries action " + humanAction.toString());
			
			// Robot's action is always #2
			
			Random random = new Random();
			Boolean reverse = random.nextBoolean();
			int numApplicable = ExperimentHelper.numberActionsApplicableInState(currentState, humanAction, robotAction, reverse);
			if (numApplicable <= 1)
			{
				String agentFailed = reverse ? "human" : "robot";
				System.out.println(agentFailed + " failed to execute action");
			}
			
			State nextState = ExperimentHelper.applyGroundedActions(currentState, humanAction, robotAction, reverse);
			
			if (reverse)
			{
				fullActions.add(robotAction);
				fullReward.add(-1.0);
				if (numApplicable > 1){
					fullActions.add(humanAction);
					fullReward.add(0.0);
				}
			}
			else
			{
				fullActions.add(humanAction);
				fullReward.add(-1.0);
				if (numApplicable > 1) {
					fullActions.add(robotAction);
					fullReward.add(0.0);
				}
			}

			ExperimentHelper.printEpisodeSequence(fullActions, fullReward);
			currentState = nextState;
		}
		ExperimentHelper.printResults(fullActions, fullReward);
		
		/* */
		endState.addObject(IngredientFactory.getNewIngredientInstance(ingredient, ingredient.getName(), domain.getObjectClass(IngredientFactory.ClassNameComplex)));
		ObjectInstance container = ContainerFactory.getNewIngredientContainerObjectInstance(domain, ingredient.getName()+"_bowl", ingredient.getName(), "shelf");
		endState.getObject(ingredient.getName()).addRelationalTarget("container", container.getName());
		endState.addObject(container);
		
		/* test */
		return endState;
	}