Package jadex.rules.examples.hanoi
Class Hanoi
- java.lang.Object
- 
- jadex.rules.examples.hanoi.Hanoi
 
- 
 public class Hanoi extends java.lang.ObjectOAV test doing towers of Hanoi.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classHanoi.HanoiComponentComponent for displaying the towers.
 - 
Field Summary
 - 
Constructor SummaryConstructors Constructor Description Hanoi()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbenchmark(int maxdiscs)Main for testing.protected static java.lang.StringcalcOverhead(double benchmark, double value)calculates overhead of second value in percent.protected static doublecalcTime(long start, int times, int discs)calculates time per move in nanoseconds.protected static IOAVStatecreateState()Create an OAV state.protected static RuleSysteminitializeRete(IOAVState state, boolean showrete)Initialize Rete system.protected static java.lang.ObjectinitState(int discs, IOAVState state, boolean showtowers)Initialize the state with the given number of discs.static voidmain(java.lang.String[] args)Main for testing.protected static voidmoveWithoutRete(IOAVState state, java.lang.Object agent, OAVAttributeType from, OAVAttributeType to, OAVAttributeType temp, int num)Solve the Hanoi puzzle using goals in state.protected static voidmoveWithoutState(java.util.List from, java.util.List to, java.util.List temp, int num)Move some discs.protected static voidmoveWithRete(IOAVState state, java.lang.Object agent, OAVAttributeType from, OAVAttributeType to, OAVAttributeType temp, int num, RuleSystem rete, boolean showrete)Move some discs with Rete algorithm.protected static voidmoveWithState(IOAVState state, java.lang.Object agent, OAVAttributeType from, OAVAttributeType to, OAVAttributeType temp, int num)Move some discs.protected static java.lang.Object[]performMoveGoal(IOAVState state, java.lang.Object agent, java.lang.Object goal)Perform a single move goal.protected static voidperformMoveGoalRecursive(IOAVState state, java.lang.Object agent, java.lang.Object goal)Recursively perform ove goals.protected static voidshowFrame(IOAVState state, java.lang.Object agent)Open a JFrame displaying the towers.protected static voidtest(int discs, int impl, boolean showtowers, boolean showrete)Test method.
 
- 
- 
- 
Field Detail- 
hanoi_type_modelpublic static final OAVTypeModel hanoi_type_model The type model.
 - 
java_oavattribute_typepublic static final OAVObjectType java_oavattribute_type The java OAV atribute type.
 - 
agent_typepublic static final OAVObjectType agent_type The agent type.
 - 
agent_has_tower_apublic static final OAVAttributeType agent_has_tower_a Agent has tower A.
 - 
agent_has_tower_bpublic static final OAVAttributeType agent_has_tower_b Agent has tower B.
 - 
agent_has_tower_cpublic static final OAVAttributeType agent_has_tower_c Agent has tower C.
 - 
agent_has_movegoalspublic static final OAVAttributeType agent_has_movegoals Agent has move goals.
 - 
disc_typepublic static final OAVObjectType disc_type The disc type.
 - 
disc_has_sizepublic static final OAVAttributeType disc_has_size Disc has size.
 - 
movegoal_typepublic static final OAVObjectType movegoal_type The move goal type.
 - 
movegoal_is_executingpublic static final OAVAttributeType movegoal_is_executing Move goal is executing.
 - 
movegoal_has_precoditionpublic static final OAVAttributeType movegoal_has_precodition Move goal has precondition.
 - 
movegoal_has_postcoditionpublic static final OAVAttributeType movegoal_has_postcodition Move goal has postcondition.
 - 
movegoal_has_frompublic static final OAVAttributeType movegoal_has_from Move goal has from.
 - 
movegoal_has_topublic static final OAVAttributeType movegoal_has_to Move goal has to.
 - 
movegoal_has_temppublic static final OAVAttributeType movegoal_has_temp Move goal has temp.
 - 
movegoal_has_numberpublic static final OAVAttributeType movegoal_has_number Move goal has number.
 
- 
 - 
Method Detail- 
mainpublic static void main(java.lang.String[] args) Main for testing.
 - 
testprotected static void test(int discs, int impl, boolean showtowers, boolean showrete)Test method. Calls one of the implementations once.
 - 
createStateprotected static IOAVState createState() Create an OAV state.
 - 
initStateprotected static java.lang.Object initState(int discs, IOAVState state, boolean showtowers)Initialize the state with the given number of discs.
 - 
benchmarkpublic static void benchmark(int maxdiscs) Main for testing.
 - 
calcTimeprotected static double calcTime(long start, int times, int discs)calculates time per move in nanoseconds.
 - 
calcOverheadprotected static java.lang.String calcOverhead(double benchmark, double value)calculates overhead of second value in percent.
 - 
moveWithoutReteprotected static void moveWithoutRete(IOAVState state, java.lang.Object agent, OAVAttributeType from, OAVAttributeType to, OAVAttributeType temp, int num) Solve the Hanoi puzzle using goals in state.
 - 
performMoveGoalRecursiveprotected static void performMoveGoalRecursive(IOAVState state, java.lang.Object agent, java.lang.Object goal) Recursively perform ove goals.
 - 
performMoveGoalprotected static java.lang.Object[] performMoveGoal(IOAVState state, java.lang.Object agent, java.lang.Object goal) Perform a single move goal.
 - 
showFrameprotected static void showFrame(IOAVState state, java.lang.Object agent) Open a JFrame displaying the towers.
 - 
moveWithStateprotected static void moveWithState(IOAVState state, java.lang.Object agent, OAVAttributeType from, OAVAttributeType to, OAVAttributeType temp, int num) Move some discs.- Parameters:
- state- The state.
- agent- The agent.
- from- The tower to move from.
- to- The tower to move to.
- temp- The tower for temporarily holding discs.
- num- The number of discs to move.
 
 - 
moveWithoutStateprotected static void moveWithoutState(java.util.List from, java.util.List to, java.util.List temp, int num)Move some discs.- Parameters:
- from- The tower to move from.
- to- The tower to move to.
- temp- The tower for temporarily holding discs.
- num- The number of discs to move.
 
 - 
initializeReteprotected static RuleSystem initializeRete(IOAVState state, boolean showrete) Initialize Rete system.- Parameters:
- state- The state.
- showrete- Show the rete structure in a JFrame.
 
 - 
moveWithReteprotected static void moveWithRete(IOAVState state, java.lang.Object agent, OAVAttributeType from, OAVAttributeType to, OAVAttributeType temp, int num, RuleSystem rete, boolean showrete) Move some discs with Rete algorithm.- Parameters:
- state- The state.
- agent- The agent.
- from- The tower to move from.
- to- The tower to move to.
- temp- The tower for temporarily holding discs.
- num- The number of discs to move.
 
 
- 
 
-