implementation.queenproblem
Class QueenProblem

java.lang.Object
  extended by implementation.queenproblem.QueenProblem
All Implemented Interfaces:
Problem<IQueenGame>, HillClimbingProblem<IQueenGame>, SimulatedAnnealingProblem<IQueenGame>, java.util.Comparator<IQueenGame>

public class QueenProblem
extends java.lang.Object
implements HillClimbingProblem<IQueenGame>, SimulatedAnnealingProblem<IQueenGame>


Constructor Summary
QueenProblem(int size)
           
 
Method Summary
 int compare(IQueenGame a, IQueenGame b)
           
 double difference(IQueenGame a, IQueenGame b)
           
 java.util.List<IQueenGame> expand(IQueenGame state)
          Generates all successor states of the given state.
 IQueenGame initial()
          Returns the starting state of the search.
 boolean isGoal(IQueenGame state)
          Checks whether a given state is a goal of the search or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

QueenProblem

public QueenProblem(int size)
Method Detail

expand

public java.util.List<IQueenGame> expand(IQueenGame state)
Description copied from interface: Problem
Generates all successor states of the given state.
This method should never return null. If the state can not be expanded than you should return an empty List.
Note: Most search algorithms have the ability to check for duplicate states, but if you want to implement your own duplicate handling than this method is the place to put it in.

Specified by:
expand in interface Problem<IQueenGame>
Parameters:
state - to be expanded
Returns:
a List of all successor states

initial

public IQueenGame initial()
Description copied from interface: Problem
Returns the starting state of the search.
Note: In some cases (e.g. HillClimbing) it is feasible to return a random generated state, instead of one single starting state.

Specified by:
initial in interface Problem<IQueenGame>
Returns:
the initial state of your search domain

isGoal

public boolean isGoal(IQueenGame state)
Description copied from interface: Problem
Checks whether a given state is a goal of the search or not.

Specified by:
isGoal in interface Problem<IQueenGame>
Parameters:
state - to be checked
Returns:
true only if the state is one of the goal states

compare

public int compare(IQueenGame a,
                   IQueenGame b)
Specified by:
compare in interface java.util.Comparator<IQueenGame>

difference

public double difference(IQueenGame a,
                         IQueenGame b)
Specified by:
difference in interface SimulatedAnnealingProblem<IQueenGame>
Returns: