Last active
August 29, 2015 14:02
-
-
Save pablormier/4f8c44fc235f1047a7fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Action { UP, DOWN, LEFT, RIGHT } | |
Hipster.SearchProblem p = | |
ProblemBuilder.create() | |
.initialState(Arrays.asList(5,4,0,7,2,6,8,1,3)) | |
.defineProblemWithExplicitActions() | |
.useActionFunction(new ActionFunction<Action, List<Integer>>() { | |
public Iterable<Action> actionsFor(List<Integer> board) { | |
return validMovements(board); | |
} | |
}).useTransitionFunction(new ActionStateTransitionFunction<Action, List<Integer>>() { | |
public List<Integer> apply(Action action, List<Integer> board) { | |
return applyActionToBoard(action, board); | |
} | |
}).useCostFunction(new CostFunction<Action, List<Integer>, Double>() { | |
public Double evaluate(Transition<Action, List<Integer>> transition) { | |
return 1d; | |
} | |
}).build(); | |
System.out.println(Hipster.createAStar(p).search(Arrays.asList(0,1,2,3,4,5,6,7,8))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment