|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectknockabout.search.MCSearchAlgorithm
A Monte Carlo search algorithm implementation
Constructor Summary | |
MCSearchAlgorithm()
|
Method Summary | |
int |
getAverageBranchingFactor()
Average branching factor |
float |
getBestMoveUtility()
|
int |
getD()
|
Heuristic |
getHeuristic()
|
GameState |
getInitialState()
|
int |
getK()
|
int |
getMaxDepth()
|
int |
getNumberOfExploredNodes()
Number of min nodes + number of max nodes explored |
protected float |
MC(GameState state)
MC() check the average of k simulations for the given state |
Move |
search()
Evaluate the best move to do |
void |
setD(int i)
|
void |
setHeuristic(Heuristic heuristic)
The heuristic function to evaluate the utility of non terminal nodes |
void |
setInitialState(GameState initialState)
The initial state of the game |
void |
setK(int i)
|
protected float |
simulate(GameState state,
int depth,
int color)
Simulate a line of the game Half of the time, we pick the best move using a greedy minmax, half of the time we pick a random move For the chance node, we pick one value of the die at random |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MCSearchAlgorithm()
Method Detail |
public GameState getInitialState()
getInitialState
in interface SearchAlgorithm
public void setInitialState(GameState initialState)
SearchAlgorithm
setInitialState
in interface SearchAlgorithm
initialState
- public Move search()
SearchAlgorithm
search
in interface SearchAlgorithm
protected float MC(GameState state)
state
-
protected float simulate(GameState state, int depth, int color)
state
- The state from where the simulation beginsdepth
- The required depth of the simulationcolor
- The color of the player currently simulated (alternates)
public float getBestMoveUtility()
getBestMoveUtility
in interface SearchAlgorithm
public int getNumberOfExploredNodes()
SearchAlgorithm
getNumberOfExploredNodes
in interface SearchAlgorithm
public int getAverageBranchingFactor()
SearchAlgorithm
getAverageBranchingFactor
in interface SearchAlgorithm
public int getD()
public int getK()
public void setD(int i)
i
- public void setK(int i)
i
- public Heuristic getHeuristic()
getHeuristic
in interface SearchAlgorithm
public void setHeuristic(Heuristic heuristic)
SearchAlgorithm
setHeuristic
in interface SearchAlgorithm
heuristic
- public int getMaxDepth()
getMaxDepth
in interface SearchAlgorithm
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |