Class State

  • All Implemented Interfaces:
    java.lang.Comparable<State>

    public class State
    extends java.lang.Object
    implements java.lang.Comparable<State>
    The states used in the AI algorithms
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  State.Type
      The type of operation
    • Constructor Summary

      Constructors 
      Constructor Description
      State​(int x, int y, State.Type operation, State predecessor, int importance)
      Initialize the state
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(State that)
      This is used to compare priorities in a priority queue
      boolean equals​(java.lang.Object object)
      Overridden equals to compare the x and y coordinates
      int getImportance()
      Get the importance of the state
      State.Type getOperation()
      Get the operation to perform
      State getPredecessor()
      Get the previous state
      int getX()
      Get the x position of the state
      int getY()
      Get the y position of the state
      int hashCode()  
      void setPriority​(double priority)
      Set the priority of a given state
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • State

        public State​(int x,
                     int y,
                     State.Type operation,
                     State predecessor,
                     int importance)
        Initialize the state
        Parameters:
        x - The x position
        y - The y position
        operation - The operation to perform
        predecessor - The previous state
        importance - The importance of the objective
    • Method Detail

      • getX

        public int getX()
        Get the x position of the state
        Returns:
        The x coordinate
      • getY

        public int getY()
        Get the y position of the state
        Returns:
        The y coordinate
      • getOperation

        public State.Type getOperation()
        Get the operation to perform
        Returns:
        The operation to perform
      • getPredecessor

        public State getPredecessor()
        Get the previous state
        Returns:
        The previous state
      • getImportance

        public int getImportance()
        Get the importance of the state
        Returns:
        Returns the importance
      • setPriority

        public void setPriority​(double priority)
        Set the priority of a given state
        Parameters:
        priority - The priority value
      • equals

        public boolean equals​(java.lang.Object object)
        Overridden equals to compare the x and y coordinates
        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - The object to compare with this
        Returns:
        Returns true if they are the same or false otherwise
      • compareTo

        public int compareTo​(State that)
        This is used to compare priorities in a priority queue
        Specified by:
        compareTo in interface java.lang.Comparable<State>
        Parameters:
        that - The state to compare
        Returns:
        Returns the value of Double.compare()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object