Class ComputerFigure

    • Field Detail

      • speedCount

        protected int speedCount
        A counter for the number fo moves to wait until moving on.
      • wantsToEnterBlue

        protected boolean wantsToEnterBlue
        Flag, if this figure currently wants to enter blue points. This is always true for this simple computer figure.
      • pointList

        protected java.util.ArrayList<Point> pointList
        List of points equally rated at target determination.
    • Constructor Detail

      • ComputerFigure

        public ComputerFigure​(Game game,
                              FigureInfo f)
        Creates a new computer figure on the field. Its energy is set to 120, its maximum energy to 250. This simple computer figure will always use an item, as soon as it gets it, without determining, if this currently makes sense. This figures speed is set to the current levels standard speed.
        Parameters:
        game - The game.
        f - The FigureInfo.
    • Method Detail

      • getIq

        public int getIq()
        Gets the IQ of this figure. If the background is flickering, the figures iq is reduced by 20.
        Overrides:
        getIq in class Figure
        Returns:
        The IQ.
      • doCalculateNextPoint

        protected Point doCalculateNextPoint()
        This is called once each round to determine the next point the figure wants to occupy. Override this method in ComputerFigure-subclasses to implement an own move strategy. This default implementation will first check, if the figures wants to move by calling the wantsToMove-method. If it wants to move, it calls the calculateNextPoint-method, to check the currently occupied point and the points around, and returns the point with the highest rating.
        Overrides:
        doCalculateNextPoint in class Figure
        Returns:
        The point, this figure wants to move to.
      • wantsToMove

        protected boolean wantsToMove()
        Checks, if this figure wants to move.
        Returns:
        true, if either speedCount is reached or this figures point is exploding.
      • doSpecialUpdate

        protected void doSpecialUpdate​(AnimationInfo animation)
        Special updates. Sets the wantsToUSeItem-flag to true, if the figure owns an item.
        Overrides:
        doSpecialUpdate in class Figure
        Parameters:
        animation - AnimationInfo
      • calculateNextPoint

        protected final Point calculateNextPoint()
        Calculates the best next point by checking the currently occupied and its surrounding points. Calls the getPointRating(Point)-method for each of these five points to determine the best point rating. If more than one points are rated equally, one of these is randomly chosen.
        Returns:
        The best point for this figure.
      • findClosestEnemy

        protected Figure findClosestEnemy()
        Searches for the closest enemy figure on the field. Enemies are checked for relevance by checkEnemy-method.
        Returns:
        The closest (visible) enemy.
      • checkEnemy

        protected boolean checkEnemy​(Figure f)
        Checks, if a figure is relevant for the closest enemy determination.
        Parameters:
        f - The figure.
        Returns:
        true, if figure is not this figure, is visible and ok.
      • isVisible

        protected boolean isVisible​(Figure f)
        Checks, if the figure f is visible to this figure.
        Parameters:
        f - The figure to check
        Returns:
        true, if the figure is visible.
      • getDistance

        protected int getDistance​(Point p)
        Gets the distance from this figure to the Point.
        Parameters:
        p - The point.
        Returns:
        The distance in moves.
      • getDistance

        protected int getDistance​(Point p1,
                                  Point p2)
        Gets the distance between two points.
        Parameters:
        p1 - The first point.
        p2 - The second point.
        Returns:
        The distance in moves.
      • entersExplosion

        protected boolean entersExplosion()
        Checks, if this figure wants to enter an explosion.
        Returns:
        false by default.
      • calculatePointRating

        protected int calculatePointRating​(Point p)
        Gets the point rating for a given point during next point calculation - override this method in own computer figure implementations if you want reuse the calculateNextPoint()-method for the way the next point is basically retrieved. The simple computer figure takes into account the item that lies on the point and its color. The simple computer figure likes moving to blue points most.
        Parameters:
        p - the point.
        Returns:
        Rating for the point.
      • modifyByColor

        protected int modifyByColor​(Point p,
                                    int currentRating)
        Modifies the point rating by the points color rating.
        Parameters:
        p - The point
        currentRating - The current rating for the point.
        Returns:
        The modified rating
      • calculateItemRating

        protected int calculateItemRating​(Item item)
        Calculates a rating for the item.
        Parameters:
        item - The item
        Returns:
        The rating
      • isForbiddenItem

        protected boolean isForbiddenItem​(Item i)
        Checks, if the item is not allowed to be picked up by this figure.
        Parameters:
        i - The item.
        Returns:
        true, if item must not be picked up.
      • isUnwantedItem

        protected boolean isUnwantedItem​(Item i)
        Checks, if the item is not wanted to be picked up by this figure.
        Parameters:
        i - The item.
        Returns:
        true, if item must not be picked up.
      • isRamTarget

        protected boolean isRamTarget​(Figure f)
        Checks, if the figure is a good ram target (because it is weaker than this figure).
        Parameters:
        f - The figure to check.
        Returns:
        true, if the figure is a good ram target
      • isDummy

        public boolean isDummy()
        Checks, if figure is a dummy
        Overrides:
        isDummy in class Figure
        Returns:
        false
      • isApplyingLevelInfoIQ

        public boolean isApplyingLevelInfoIQ()
        Checks, if level IQ setting should be applied to this figure.
        Overrides:
        isApplyingLevelInfoIQ in class Figure
        Returns:
        true.