Class CleverComputerFigureMK2

    • Field Detail

      • DEBUGDETAIL2

        public static boolean DEBUGDETAIL2
        Debug flag for detailed pointrating output.
      • DRAWDEBUG

        public static boolean DRAWDEBUG
        Debug flags that draws the clever figures current target point and ratings on the field.
      • targetItem

        protected Item targetItem
        The current target item of the figure.
      • targetFigure

        protected Figure targetFigure
        The current target figure of the figure.
      • target

        protected com.starpoints.game.figure.CleverComputerFigureMK2.TargetDescriptor target
        The current target type.
      • targets

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

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

      • CleverComputerFigureMK2

        public CleverComputerFigureMK2​(Game game,
                                       FigureInfo figureInfo)
        Creates a new CleverComputerFigure MK2 with IQ 120.
        Parameters:
        game - The Game.
        figureInfo - The FigureInfo.
    • Method Detail

      • addStateProperties

        protected void addStateProperties​(ThingState state,
                                          AnimationInfo animation)
        Adds debug properties necessary for thing painting.
        Overrides:
        addStateProperties in class Thing
        Parameters:
        state - The state to add properties to.
        animation - The current AnimationInfo.
      • 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.
      • isApplyingLevelInfoIQ

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

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

        protected void doSpecialUpdate​(AnimationInfo animation)
        This method is called at the end of the regular updateThing()-method. Lets all surrounding points explode.
        Overrides:
        doSpecialUpdate in class ComputerFigure
        Parameters:
        animation - The AnimationInfo.
      • onRoundBegin

        public void onRoundBegin​(AnimationInfo animation)
        This method is called at the beginning of each round. 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:
        onRoundBegin in class Figure
        Parameters:
        animation - The AnimationInfo.
      • updateRatingModifiers

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

        protected Point doCalculateNextPoint()
        This is called once each round to determine the next point the figure wants to occupy.
        Overrides:
        doCalculateNextPoint in class ComputerFigure
        Returns:
        The point, this figure wants to move to.
      • isPointTooDangerousForHurryingBecauseOfEnergyLoss

        public boolean isPointTooDangerousForHurryingBecauseOfEnergyLoss​(Point p)
        Checks, if p is dangerous during hurrying due to energy loss.
        Parameters:
        p - The Point
        Returns:
        true, if p is dangerous during hurrying due to energy loss.
      • determineItemUsage

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

        protected boolean wantsToUseBigMine()
        Checks, if a big mine should be used.
        Returns:
        true, if a big mine should be used.
      • wantsToUseRocket

        protected boolean wantsToUseRocket()
        Checks, if a rocket should be used.
        Returns:
        true, if a rocket should be used.
      • calculateScoreDifferenceToSecond

        public int calculateScoreDifferenceToSecond()
        Calculates the score difference to the second best player in the level.
        Returns:
        Score difference to the second best player in the level.
      • calculateScoreDifferenceToLead

        public int calculateScoreDifferenceToLead()
        Calculates the score difference to the best player in the level.
        Returns:
        Score difference to the second best player in the level.
      • getPointRating

        protected int getPointRating​(Point p,
                                     boolean modifyByTargetDirection)
        Gets the calculated point rating (as determined in last rateField()-call).
        Parameters:
        p - The point.
        modifyByTargetDirection - Flag, if target direction should be taken into account.
        Returns:
        The point rating.
      • getPointDangerRating

        protected int getPointDangerRating​(Point p)
        Gets the calculated point danger rating (as determined in last rateField()-call).
        Parameters:
        p - The point.
        Returns:
        The danger rating.
      • calculatePointRating

        protected int calculatePointRating​(Point p)
        Gets a point rating for a given point. Adds ratings for color, occupant, fog and heat.
        Overrides:
        calculatePointRating in class ComputerFigure
        Parameters:
        p - the point.
        Returns:
        Rating for the point.
      • calculateFogRating

        protected int calculateFogRating​(Point p,
                                         boolean stay)
        Gets a rating for the fog on a point.
        Parameters:
        p - The point.
        stay - Flag, if figure stays in the fog.
        Returns:
        A rating modification because of the fog.
      • calculateTargetDirectionRating

        protected int calculateTargetDirectionRating​(Point p)
        Returns a positive rating modifier, if p is in the target direction.
        Parameters:
        p - The point
        Returns:
        The rating.
      • 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.
      • isHeatSource

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

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

        protected int calculateRatingModifiers​(Point p)
        Modifies the point rating by the rating modifiers.
        Parameters:
        p - The point
        Returns:
        The modified rating.
      • hasFreeSlot

        protected boolean hasFreeSlot()
        Checks, if this figure has a fire extinguisher.
        Returns:
        true, if this figure has a fire extinguisher.
      • 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 cool generator.
        Returns:
        true, if this figure has a cool generator.
      • hasEnergyTransformer

        protected boolean hasEnergyTransformer()
        Checks, if this figure has an energy transformer.
        Returns:
        true, if this figure has an energy transformer.
      • getRegenerationPower

        protected int getRegenerationPower()
        Calculates, how much energy is gained by regeneraton items.
        Returns:
        The regeneration power.
      • 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.
      • isAffectedByDarkRedInternal

        protected boolean isAffectedByDarkRedInternal()
        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.
      • isInLead

        protected boolean isInLead()
        Checks, if this figure is in lead in the current level.
        Returns:
        true, if in lead.
      • 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
      • 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.
      • 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.