Class Hanoi


  • public class Hanoi
    extends java.lang.Object
    OAV test doing towers of Hanoi.
    • Field Detail

      • hanoi_type_model

        public static final OAVTypeModel hanoi_type_model
        The type model.
      • java_oavattribute_type

        public static final OAVObjectType java_oavattribute_type
        The java OAV atribute type.
      • agent_type

        public static final OAVObjectType agent_type
        The agent type.
      • agent_has_tower_a

        public static final OAVAttributeType agent_has_tower_a
        Agent has tower A.
      • agent_has_tower_b

        public static final OAVAttributeType agent_has_tower_b
        Agent has tower B.
      • agent_has_tower_c

        public static final OAVAttributeType agent_has_tower_c
        Agent has tower C.
      • agent_has_movegoals

        public static final OAVAttributeType agent_has_movegoals
        Agent has move goals.
      • disc_type

        public static final OAVObjectType disc_type
        The disc type.
      • disc_has_size

        public static final OAVAttributeType disc_has_size
        Disc has size.
      • movegoal_type

        public static final OAVObjectType movegoal_type
        The move goal type.
      • movegoal_is_executing

        public static final OAVAttributeType movegoal_is_executing
        Move goal is executing.
      • movegoal_has_precodition

        public static final OAVAttributeType movegoal_has_precodition
        Move goal has precondition.
      • movegoal_has_postcodition

        public static final OAVAttributeType movegoal_has_postcodition
        Move goal has postcondition.
      • movegoal_has_from

        public static final OAVAttributeType movegoal_has_from
        Move goal has from.
      • movegoal_has_to

        public static final OAVAttributeType movegoal_has_to
        Move goal has to.
      • movegoal_has_temp

        public static final OAVAttributeType movegoal_has_temp
        Move goal has temp.
      • movegoal_has_number

        public static final OAVAttributeType movegoal_has_number
        Move goal has number.
    • Constructor Detail

      • Hanoi

        public Hanoi()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
        Main for testing.
      • test

        protected static void test​(int discs,
                                   int impl,
                                   boolean showtowers,
                                   boolean showrete)
        Test method. Calls one of the implementations once.
      • createState

        protected static IOAVState createState()
        Create an OAV state.
      • initState

        protected static java.lang.Object initState​(int discs,
                                                    IOAVState state,
                                                    boolean showtowers)
        Initialize the state with the given number of discs.
      • benchmark

        public static void benchmark​(int maxdiscs)
        Main for testing.
      • calcTime

        protected static double calcTime​(long start,
                                         int times,
                                         int discs)
        calculates time per move in nanoseconds.
      • calcOverhead

        protected static java.lang.String calcOverhead​(double benchmark,
                                                       double value)
        calculates overhead of second value in percent.
      • performMoveGoalRecursive

        protected static void performMoveGoalRecursive​(IOAVState state,
                                                       java.lang.Object agent,
                                                       java.lang.Object goal)
        Recursively perform ove goals.
      • performMoveGoal

        protected static java.lang.Object[] performMoveGoal​(IOAVState state,
                                                            java.lang.Object agent,
                                                            java.lang.Object goal)
        Perform a single move goal.
      • showFrame

        protected static void showFrame​(IOAVState state,
                                        java.lang.Object agent)
        Open a JFrame displaying the towers.
      • moveWithState

        protected 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.
      • moveWithoutState

        protected 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.
      • initializeRete

        protected static RuleSystem initializeRete​(IOAVState state,
                                                   boolean showrete)
        Initialize Rete system.
        Parameters:
        state - The state.
        showrete - Show the rete structure in a JFrame.
      • moveWithRete

        protected 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.