public void TestIsTigerGoalState() { State s = new State(); Board b = s.Board; Assert.IsNotNull(b); Assert.IsNotNull(b.GetSpace(2,2)); Assert.IsNotNull(s.GetSpaceState(2,2)); GoatPlacementMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat); TigerCaptureMove t1 = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger); TigerCaptureMove t2 = new TigerCaptureMove(b.GetSpace(2,2), b.GetSpace(0,4), b.GetSpace(1, 3), s.Tiger); Assert.IsFalse(s.IsTigerGoalState()); Assert.IsFalse(s.IsGoatGoalState()); g.ExecuteMove(s); t1.ExecuteMove(s); // 1 down g.ExecuteMove(s); t2.ExecuteMove(s); // 2 down g.ExecuteMove(s); t1.ExecuteMove(s); // 3 down g.ExecuteMove(s); t2.ExecuteMove(s); // 4 down g.ExecuteMove(s); t1.ExecuteMove(s); //5 down Assert.IsTrue(s.IsTigerGoalState()); Assert.IsFalse(s.IsGoatGoalState()); }
public double GetEvaluation(State currState) { if (currState.IsTigerGoalState()) return 1000.0; if (currState.IsGoatGoalState()) return -1000.0; int killed = currState.Goat.GoatsKilled; double moveQuot = currState.Tiger.GetCountLegalMoves(currState) /30.0; return killed + moveQuot; }
private double minValue(State state, int depthLimit, List<AbstractMove> moves) { if (state.IsGoatGoalState() || state.IsTigerGoalState() || depthLimit == 0) { return getTigerEval(state); } double v = 1000; State hypoState; foreach (AbstractMove m in moves) { hypoState = state.Clone(); m.ExecuteMove(hypoState); List<AbstractMove> newMoves = hypoState.findTigerMoves(); m.Value = maxValue(hypoState, (depthLimit - 1), newMoves); v = minimum(v, m.Value); } if (v <= alpha) return v; beta = minimum(beta, v); return v; }
private double maxNoPrune(State state, int depthLimit, List<AbstractMove> moves) { if (state.IsGoatGoalState() || state.IsTigerGoalState() || depthLimit == 0) { return getTigerEval(state); } double v = -1000; State hypoState; foreach (AbstractMove m in moves) { hypoState = state.Clone(); m.ExecuteMove(hypoState); List<AbstractMove> newMoves = hypoState.findGoatMoves(); m.Value = minNoPrune(hypoState, (depthLimit - 1), newMoves); v = maximum(v, m.Value); } return v; }