Fixed unit tests, changed MDP generation to more reasonably seek the goal state, avoiding premature end of game.
Removed unused google-code classes. Regenerate policy when AdaptiveComPlayer.setTarget() is called.
This commit is contained in:
@@ -6,10 +6,6 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import aima.core.environment.cellworld.Cell;
|
||||
import aima.core.environment.cellworld.CellWorld;
|
||||
import aima.core.environment.cellworld.CellWorldAction;
|
||||
import aima.core.environment.cellworld.CellWorldFactory;
|
||||
import aima.core.environment.gridworld.GridCell;
|
||||
import aima.core.environment.gridworld.GridWorld;
|
||||
import aima.core.environment.gridworld.GridWorldAction;
|
||||
@@ -19,29 +15,30 @@ import aima.core.probability.mdp.MarkovDecisionProcess;
|
||||
import aima.core.probability.mdp.search.ValueIteration;
|
||||
|
||||
/**
|
||||
* @author Ravi Mohan
|
||||
* @author Ciaran O'Reilly
|
||||
*
|
||||
* @author Woody
|
||||
*
|
||||
*/
|
||||
public class ValueIterationTest2 {
|
||||
public static final double DELTA_THRESHOLD = 1e-3;
|
||||
|
||||
private GridWorld<Double> gw = null;
|
||||
private MarkovDecisionProcess<GridCell<Double>, GridWorldAction> mdp = null;
|
||||
private MarkovDecisionProcess<GridCell<Double>, GridWorldAction> mdp = null;
|
||||
private ValueIteration<GridCell<Double>, GridWorldAction> vi = null;
|
||||
|
||||
final int maxTiles = 6;
|
||||
final int maxScore = 10;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
//take 10 turns to place 6 tiles
|
||||
// take 10 turns to place 6 tiles
|
||||
double defaultPenalty = -0.04;
|
||||
|
||||
gw = GridWorldFactory.createGridWorldForTileGame(maxTiles,maxScore,defaultPenalty);
|
||||
|
||||
gw = GridWorldFactory.createGridWorldForTileGame(maxTiles, maxScore,
|
||||
defaultPenalty);
|
||||
mdp = MDPFactory.createMDPForTileGame(gw, maxTiles, maxScore);
|
||||
|
||||
//gamma = 1.0
|
||||
|
||||
// gamma = 1.0
|
||||
vi = new ValueIteration<GridCell<Double>, GridWorldAction>(0.9);
|
||||
}
|
||||
|
||||
@@ -57,20 +54,7 @@ public class ValueIterationTest2 {
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
|
||||
Assert.assertEquals(0.705, U.get(gw.getCellAt(1, 1)), DELTA_THRESHOLD);/*
|
||||
Assert.assertEquals(0.762, U.get(cw1.getCellAt(1, 2)), DELTA_THRESHOLD);
|
||||
Assert.assertEquals(0.812, U.get(cw1.getCellAt(1, 3)), DELTA_THRESHOLD);
|
||||
|
||||
Assert.assertEquals(0.655, U.get(cw1.getCellAt(2, 1)), DELTA_THRESHOLD);
|
||||
Assert.assertEquals(0.868, U.get(cw1.getCellAt(2, 3)), DELTA_THRESHOLD);
|
||||
|
||||
Assert.assertEquals(0.611, U.get(cw1.getCellAt(3, 1)), DELTA_THRESHOLD);
|
||||
Assert.assertEquals(0.660, U.get(cw1.getCellAt(3, 2)), DELTA_THRESHOLD);
|
||||
Assert.assertEquals(0.918, U.get(cw1.getCellAt(3, 3)), DELTA_THRESHOLD);
|
||||
|
||||
Assert.assertEquals(0.388, U.get(cw1.getCellAt(4, 1)), DELTA_THRESHOLD);
|
||||
Assert.assertEquals(-1.0, U.get(cw1.getCellAt(4, 2)), DELTA_THRESHOLD);
|
||||
Assert.assertEquals(1.0, U.get(cw1.getCellAt(4, 3)), DELTA_THRESHOLD);*/
|
||||
Assert.assertEquals(-0.1874236, U.get(gw.getCellAt(1, 1)), DELTA_THRESHOLD);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user