<commit_before>package aima.test.probdecisiontest;

import aima.probability.Randomizer;
import aima.probability.decision.MDP;
import aima.probability.decision.MDPFactory;
import aima.probability.decision.MDPPolicy;
import aima.probability.decision.MDPUtilityFunction;
import aima.probability.decision.cellworld.CellWorldPosition;
import aima.test.probabilitytest.MockRandomizer;
import junit.framework.TestCase;

public class PolicyIterationTest extends TestCase {
	private MDP<CellWorldPosition, String> fourByThreeMDP;

	private Randomizer alwaysLessThanEightyPercent;

	public void setUp() {
		fourByThreeMDP = MDPFactory.createFourByThreeMDP();
		
	}

	public void testPolicyEvaluation() {
		MDPPolicy<CellWorldPosition, String> policy = fourByThreeMDP.randomPolicy();
		MDPUtilityFunction<CellWorldPosition> uf1 = fourByThreeMDP
				.initialUtilityFunction();
		// System.out.println("before " +uf1);
		MDPUtilityFunction<CellWorldPosition> uf2 = fourByThreeMDP
				.policyEvaluation(policy, uf1, 1, 3);
		// System.out.println("after " +uf2);

		assertFalse(uf1.equals(uf2));

	}
	
	public void testPolicyIteration(){
	
		MDPPolicy<CellWorldPosition, String> policy = fourByThreeMDP.policyIteration(1);		
		//check With Figure 17.2 (a)
		System.out.println("policy after = " + policy);
		assertEquals("up", policy.getAction(new CellWorldPosition(1,1)));
		assertEquals("up", policy.getAction(new CellWorldPosition(2,1)));
		assertEquals("right", policy.getAction(new CellWorldPosition(3,1)));
		
		assertEquals("left", policy.getAction(new CellWorldPosition(1,2)));
		assertEquals("right", policy.getAction(new CellWorldPosition(3,2)));
		
		assertEquals("left", policy.getAction(new CellWorldPosition(1,3)));
		assertEquals("up", policy.getAction(new CellWorldPosition(2,3)));<commit_msg>commented out print ln<commit_after>package aima.test.probdecisiontest;

import aima.probability.Randomizer;
import aima.probability.decision.MDP;
import aima.probability.decision.MDPFactory;
import aima.probability.decision.MDPPolicy;
import aima.probability.decision.MDPUtilityFunction;
import aima.probability.decision.cellworld.CellWorldPosition;
import aima.test.probabilitytest.MockRandomizer;
import junit.framework.TestCase;

public class PolicyIterationTest extends TestCase {
	private MDP<CellWorldPosition, String> fourByThreeMDP;

	private Randomizer alwaysLessThanEightyPercent;

	public void setUp() {
		fourByThreeMDP = MDPFactory.createFourByThreeMDP();
		
	}

	public void testPolicyEvaluation() {
		MDPPolicy<CellWorldPosition, String> policy = fourByThreeMDP.randomPolicy();
		MDPUtilityFunction<CellWorldPosition> uf1 = fourByThreeMDP
				.initialUtilityFunction();
		// System.out.println("before " +uf1);
		MDPUtilityFunction<CellWorldPosition> uf2 = fourByThreeMDP
				.policyEvaluation(policy, uf1, 1, 3);
		// System.out.println("after " +uf2);

		assertFalse(uf1.equals(uf2));

	}
	
	public void testPolicyIteration(){
	
		MDPPolicy<CellWorldPosition, String> policy = fourByThreeMDP.policyIteration(1);		
		//check With Figure 17.2 (a)
		//System.out.println("policy after = " + policy);
		assertEquals("up", policy.getAction(new CellWorldPosition(1,1)));
		assertEquals("up", policy.getAction(new CellWorldPosition(2,1)));
		assertEquals("right", policy.getAction(new CellWorldPosition(3,1)));
		
		assertEquals("left", policy.getAction(new CellWorldPosition(1,2)));
		assertEquals("right", policy.getAction(new CellWorldPosition(3,2)));
		
		assertEquals("left", policy.getAction(new CellWorldPosition(1,3)));
		assertEquals("up", policy.getAction(new CellWorldPosition(2,3)));
{'fraction_non_alphanumeric': 0.12052207720077757, 'fraction_numerical': 0.014995834490419328, 'mean_word_length': 6.663829787234042, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '10581', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1109, 'n_words': 190}