Class CleverComputerFigure

    • Field Detail

      • BIGMINE_PLACED

        protected static final int BIGMINE_PLACED
        Hurrying reason bit value for a placed BigMine.
        See Also:
        Constant Field Values
      • ROCKET_ACTIVE

        protected static final int ROCKET_ACTIVE
        Hurrying reason bit value for an active rocket.
        See Also:
        Constant Field Values
      • INVULNERABLE

        protected static final int INVULNERABLE
        Hurrying reason bit value for i invulerable.
        See Also:
        Constant Field Values
      • ENEMY_NEARBY

        protected static final int ENEMY_NEARBY
        Hurrying reason bit value for a dangerous enemy nearby.
        See Also:
        Constant Field Values
      • hurrySpeed

        protected int hurrySpeed
        The speed during hurrying phases.
      • hurryingReason

        protected int hurryingReason
        The reason for hurrying. Bit-coded, in case multiple reasons for hurrying exist.
      • target

        protected Point target
        The current target point of the figure.
      • danger

        protected boolean danger
        Flag, if a danger - either active rocket or bigmine - was detected on the field.
      • targetRadius

        protected int targetRadius
        The radius in which a target is determined.
      • targetCountDown

        protected int targetCountDown
        Counter for searching a new target.
      • targetRating

        protected int targetRating
        The rating of the current target.
      • bigMine

        protected Item bigMine
        A big mine that was used by the figure.
      • rocket

        protected Item rocket
        A rocket that was used by the figure.
      • nearestEnemy

        protected Figure nearestEnemy
        the nearest enemy.
      • aggressiveness

        protected int aggressiveness
        Value for the aggressiveness of this figure, used for rating aspects. Default value is 800.
      • purposefulness

        protected int purposefulness
        Value for the focus of this figure, to find a way to the current target point. Default value is 800.
      • targets

        protected java.util.ArrayList<Point> targets
        The list of points to the current target point.
      • ratingModifier

        protected java.util.List<RatingModifier> ratingModifier
        A map of modifiers for rockets and bigmines placed on the field.
    • Constructor Detail

      • CleverComputerFigure

        public CleverComputerFigure​(Game game,
                                    FigureInfo figureInfo)
        Creates a new CleverComputerFigure.
        Parameters:
        game - The Game.
        figureInfo - 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 ComputerFigure
        Returns:
        The IQ.
      • doSpecialUpdate

        protected void doSpecialUpdate​(AnimationInfo animation)
        This method is called at the end of the regular updateThing()-method. This performs the following steps: - Update the rating modifiers for bombs and rockets.
        - Check, if the current point is dangerous and is a reason for a direct move.
        - Check, if the nearest enemy is still a danger.
        - Select a new target point, if not in panic.
        - Check, if an item should be used.
        Overrides:
        doSpecialUpdate in class ComputerFigure
        Parameters:
        animation - The AnimationInfo.
      • wantsToMove

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

        protected boolean isVisible​(Figure f)
        Checks, if the figure f is visible to this figure.
        Overrides:
        isVisible in class ComputerFigure
        Parameters:
        f - The figure to check
        Returns:
        true, if the figure is visible, or it has moved recently and this figure has an IQ greater or equal 140 or if this figure has an IQ of 200 and knows everything.
      • determineItemUsage

        public void determineItemUsage()
        Checks, if the figure wants to use an item it carries around.
      • checkRamPowerForUsage

        protected void checkRamPowerForUsage()
        Checks, if a ram power item should be used.
      • checkShieldingForUsage

        protected void checkShieldingForUsage()
        Checks, if a shield item should be used.
      • checkBigMineUsage

        protected void checkBigMineUsage()
        Checks, if a big mine should be used.
      • checkRocketUsage

        protected void checkRocketUsage()
        Checks, if a rocket should be used.
      • selectNewTargetPoint

        protected void selectNewTargetPoint()
        Selects a new target on the field.
      • checkIfNewTargetShouldBeSelected

        protected boolean checkIfNewTargetShouldBeSelected()
        Checks, if the figure wants to select a new target.
        Returns:
        true, if new target should be selected.
      • getTargetRating

        protected int getTargetRating​(Point target)
        Gets the point rating for the given target point to check.
        Parameters:
        target - The point to calculate the rating for
        Returns:
        The point rating as target.
      • checkHurryingBecauseOfEnemyNearby

        protected void checkHurryingBecauseOfEnemyNearby()
        Checks, if the nearest enemy is still a reason for hurrying.
      • checkHurryingBecauseOfPointColor

        protected boolean checkHurryingBecauseOfPointColor()
        Checks, if the color of the current point is a reason to move fast.
        Returns:
        true, if figures point is dangerous.
      • updateRatingModifiers

        protected void updateRatingModifiers()
        Updates the list of modifiers for detected rockets and big mines.
      • calculatePointRating

        protected int calculatePointRating​(Point p)
        Gets the point rating for the given point for determining the best next point for this figure. Retrieves the rating for the point according to item, color, and modifies it by checking if it is target direction.
        Overrides:
        calculatePointRating in class ComputerFigure
        Parameters:
        p - The point.
        Returns:
        Rating for the point.
      • isRocketFirePoint

        protected boolean isRocketFirePoint​(Point p)
        Checks, if the point is the point an own rocket will be fired to.
        Parameters:
        p - The point
        Returns:
        true, if this figure hasa a rocket, wants to fire it and p is the first point in its targetline.
      • modifyBaseRatingByTargetDirection

        protected int modifyBaseRatingByTargetDirection​(Point p,
                                                        int baseRating)
        Modifies the rating, if p is in the target direction.
        Parameters:
        p - The point
        baseRating - The current rating
        Returns:
        The modified rating.
      • modifyBaseRatingByHeatEffect

        protected int modifyBaseRatingByHeatEffect​(Point p,
                                                   int baseRating)
        Modifies the rating if the point p is not the current point, and the figure is pretty hot already.
        Parameters:
        p - The point
        baseRating - The current rating
        Returns:
        The modified rating.
      • isHeatSource

        protected boolean isHeatSource​(Point p)
        Checks, if p is a source of heat.
        Parameters:
        p - The point.
        Returns:
        true, if hot.
      • selectTarget

        protected void selectTarget()
        Selects a new target for the figure.
      • handleBigMineDetection

        public void handleBigMineDetection​(Point pfx,
                                           Item i)
        Handles a new big mine detection on the field.
        Parameters:
        pfx - The point of the big mine.
        i - The big mine.
      • handleRocketDetection

        public void handleRocketDetection​(Point pfx,
                                          Item i)
        Handles a rocket detection on the field.
        Parameters:
        pfx - The point of the rocket.
        i - The rocket.
      • selectSafeTargetAfterBigMinePlacement

        protected void selectSafeTargetAfterBigMinePlacement​(int maxdistance)
        Selects a target after placing a bigmine.
        Parameters:
        maxdistance - The distance the target should have from the current point.
      • selectPanicTarget

        protected void selectPanicTarget​(Point dangerPoint,
                                         int maxdistance,
                                         int hurryingReason,
                                         Item danger)
        Selects a target after panicing because of rocket or bigmine.
        Parameters:
        dangerPoint - The dangerous point.
        maxdistance - the safe distance.
        hurryingReason - The reason for hurrying
        danger - The dangerous item.
      • findPanicTargetPoint

        public Point findPanicTargetPoint​(Point dangerPoint,
                                          int maxdistance)
        Finds a target point when in danger because of rocket or bigmine.
        Parameters:
        dangerPoint - The origin point of the danger.
        maxdistance - The danger radius around the danger point
        Returns:
        A safe point.
      • isDangerous

        protected boolean isDangerous​(Figure f)
        Checks, if the figure is dangerous.
        Parameters:
        f - The figure
        Returns:
        true, if figure is dangerous.
      • modifyByRatingModifiers

        protected int modifyByRatingModifiers​(Point p,
                                              int baseRating)
        Modifies the point rating by the rating modifiers.
        Parameters:
        p - The point
        baseRating - the surrent rating
        Returns:
        The modified rating.
      • getPointRatingInternal

        protected int getPointRatingInternal​(Point p,
                                             boolean selectTarget,
                                             boolean ignoreItems)
        Gets the point rating for a given point during next point calculation - override this method in own computer figure implementations. 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.
        selectTarget - Flag, if called during target calculation.
        ignoreItems - Flag, if items should be ignored for rating.
        Returns:
        The point rating.
      • modifyByColor

        protected int modifyByColor​(Point p,
                                    int currentRating)
        Modifies the point rating for movement.
        Overrides:
        modifyByColor in class ComputerFigure
        Parameters:
        p - The point.
        currentRating - the current rating.
        Returns:
        The modified rating.
      • modifyByBlueColor

        protected int modifyByBlueColor​(Point p,
                                        int currentRating)
        Modifies a point rating depending on blue color..
        Parameters:
        p - The point.
        currentRating - The current rating.
        Returns:
        the modified rating.
      • modifyByUnignorableColors

        protected int modifyByUnignorableColors​(Point p,
                                                int currentRating)
        Checks a points color, even if not to be checked.
        Parameters:
        p - The point
        currentRating - The previous rating
        Returns:
        A rating depending on the current rating and the points color.
      • modifyByItem

        public int modifyByItem​(int currentRating,
                                Item i)
        Modifies the rating by an item rating.
        Parameters:
        currentRating - The previous rating.
        i - The item.
        Returns:
        The modified rating.
      • rateOtherItem

        protected int rateOtherItem​(int currentRating,
                                    Item i)
        Rates other items.
        Parameters:
        currentRating - The previous rating.
        i - The item.
        Returns:
        The new rating.
      • rateWeapon

        protected int rateWeapon​(int currentRating,
                                 Item i)
        Rates weapons.
        Parameters:
        currentRating - The previous rating.
        i - The item.
        Returns:
        The new rating.
      • ratePermanentItem

        protected int ratePermanentItem​(int currentRating,
                                        Item i)
        Rates permanent items.
        Parameters:
        currentRating - The previous rating.
        i - The item.
        Returns:
        The new rating.
      • hasFireExtinguisher

        protected boolean hasFireExtinguisher()
        Checks, if this figure has a fire extinguisher.
        Returns:
        true, if this figure has a fire extinguisher.
      • hasBombKit

        protected boolean hasBombKit()
        Checks, if this figure has a bomb kit.
        Returns:
        true, if this figure has a bomb kit.
      • hasCoolGenerator

        protected boolean hasCoolGenerator()
        Checks, if this figure has a bomb kit.
        Returns:
        true, if this figure has a bomb kit.
      • isAffectedByBlackInternal

        protected boolean isAffectedByBlackInternal()
        Checks, if this figure is affected by black.
        Returns:
        false, if either naturally immune to black or a ItemBlackBlocker is owned.
      • isAffectedByGrayInternal

        protected boolean isAffectedByGrayInternal()
        Checks, if this figure is affected by gray.
        Returns:
        false, if either naturally immune to gray or a ItemGrayBlocker is owned.
      • getFogRating

        protected int getFogRating​(Point p)
        Gets a rating for the fog on a point
        Parameters:
        p - The point.
        Returns:
        A rating modification because of the fog.
      • isInLead

        protected boolean isInLead()
        Checks, if this figure is in lead in the current level.
        Returns:
        true, if in lead.
      • hurry

        protected void hurry​(int reason)
        Lets the figure hurry around for a special reason.
        Parameters:
        reason - The hurrying reason.
      • hurry

        protected void hurry​(int reason,
                             int speed)
        Lets the figure hurry around for a special reason with the given speed. If the hurry speed is slower than the current speed, it is ignored.
        Parameters:
        reason - The hurrying reason.
        speed - The hurrying speed.
      • isHurryingReason

        protected boolean isHurryingReason​(int reason)
        Checks, if the given reason is currently a reason for hurrying.
        Parameters:
        reason - The reason constant.
        Returns:
        true, if the reason is a reason for hurrying.
      • stopHurry

        protected void stopHurry​(int reason)
        Lets the figure stop hurrying for a special reason.
        Parameters:
        reason - The reason.
      • entersExplosion

        protected boolean entersExplosion​(int power)
        Checks, if this figure wants to enter an explosion.
        Parameters:
        power - The explosion power.
        Returns:
        true, if this figure would enter this explosion
      • stay

        protected void stay​(int rounds)
        Lets the figure stay on the current point for n rounds.
        Parameters:
        rounds - The number of rounds to stay.
      • moveFast

        protected void moveFast()
        Makes the figure move away the next round.
      • setTarget

        protected boolean setTarget​(Point targ,
                                    int targetRating)
        Sets this figures target point.
        Parameters:
        targ - The new target
        targetRating - The new targets rating.
        Returns:
        true, if the figures has not selected this target more than 3 times of the last 8 targets.
      • reInit

        protected void reInit​(Field f)
        Reinitializes the figure after each level.
        Overrides:
        reInit in class Figure
        Parameters:
        f - The new field
      • isInTargetDirX

        protected boolean isInTargetDirX​(Point p)
        Checks, if point is in current targets x direction.
        Parameters:
        p - The point to check.
        Returns:
        true, if point is in current targets x direction.
      • isInTargetDirY

        protected boolean isInTargetDirY​(Point p)
        Checks, if point is in current targets y direction.
        Parameters:
        p - The point to check.
        Returns:
        true, if point is in current targets y direction.
      • getBigMineRadius

        protected static int getBigMineRadius​(Item i)
        Gets the radius of a big mine explosion depending on the concrete ItemBigMine-class.
        Parameters:
        i - The Big Mine item
        Returns:
        The explosion radius
      • isApplyingLevelInfoIQ

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

        protected java.lang.String getHurryReasonString​(int reason)
        Gets a string representation for the given hurrying reason.
        Parameters:
        reason - The reason constant.
        Returns:
        A string represantation.
      • bombPlaced

        public void bombPlaced​(ItemBigMine b,
                               AnimationInfo animation)
        Method that is called when a bigmine is placed on the field.
        Specified by:
        bombPlaced in interface FieldListener
        Parameters:
        b - The bigmine
        animation - The AnimationInfo.
      • rocketStarted

        public void rocketStarted​(ItemRocket r,
                                  AnimationInfo animation)
        Sets the danger flag after a rocket was started.
        Specified by:
        rocketStarted in interface FieldListener
        Parameters:
        r - The rocket.
        animation - The AnimationInfo.