Package com.starpoints.game.figure
Class CleverComputerFigureMK2
- java.lang.Object
-
- com.starpoints.game.Thing
-
- com.starpoints.game.Figure
-
- com.starpoints.game.ComputerFigure
-
- com.starpoints.game.figure.CleverComputerFigureMK2
-
- All Implemented Interfaces:
FieldListener
,java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
CleverComputerFigureMK2_160
,CleverComputerFigureMK2_200
,LeagueFigure
public class CleverComputerFigureMK2 extends ComputerFigure implements FieldListener
A more clever computer figure, using strategies to decide whether to collect points, items, regenerate, destroy enemies etc..- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEBUGDETAIL2
Debug flag for detailed pointrating output.static boolean
DRAWDEBUG
Debug flags that draws the clever figures current target point and ratings on the field.protected java.util.List<RatingModifierMK2>
ratingModifier
A list of modifiers for rockets and bigmines placed on the field.protected com.starpoints.game.figure.CleverComputerFigureMK2.TargetDescriptor
target
The current target type.protected Figure
targetFigure
The current target figure of the figure.protected Item
targetItem
The current target item of the figure.protected java.util.ArrayList<Point>
targets
The list of points to the current target point.-
Fields inherited from class com.starpoints.game.ComputerFigure
pointList, speedCount, wantsToEnterBlue
-
Fields inherited from class com.starpoints.game.Figure
ABSMAXENERGY, affectsBlue, alreadyKilled, colorlistener, DEFAULT_FIGURE_PAINTERCLASS, dieListener, dieReason, DOWN, energylistener, heatLevel, heatlistener, hoverCount, hoverHeight, hoverlistener, imageName, initialEnergy, INITIALRAMPOWER, isRocketTarget, item, itemlistener, killer, LEFT, lives, MAXHOVERHEIGHT, maxRadius, MAXSLOTS, money, moved, movelistener, name, NONE, number, oldItem, oldRocketXP, oldRocketYP, PANIC, penalty, permItems, pointBonus, pointlistener, points, ramlistener, ramPower, RIGHT, side, sinker, slots, STEPLEFT, STEPRIGHT, stunCount, stunlistener, sumPoints, UP, USE_ITEM, viewDir, visibilitylistener, visibleCount, wantsToUseItem, winCounter
-
Fields inherited from class com.starpoints.game.Thing
energy, energyFx, energyMaxSoundPlayed, energyModifications, explosionCounter, game, innerColor, invulnCount, isAffectedByBlack, isAffectedByGray, level, MAX_TEXTPAINT, maxEnergy, nextID, outerColor, p, shieldCount, status, text
-
-
Constructor Summary
Constructors Constructor Description CleverComputerFigureMK2(Game game, FigureInfo figureInfo)
Creates a new CleverComputerFigure MK2 with IQ 120.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addStateProperties(ThingState state, AnimationInfo animation)
Adds debug properties necessary for thing painting.void
bombPlaced(ItemBigMine b, AnimationInfo animation)
Method that is called when a bigmine is placed on the field.protected int
calculateFogRating(Point p, boolean stay)
Gets a rating for the fog on a point.protected int
calculatePointRating(Point p)
Gets a point rating for a given point.protected int
calculateRatingModifiers(Point p)
Modifies the point rating by the rating modifiers.int
calculateScoreDifferenceToLead()
Calculates the score difference to the best player in the level.int
calculateScoreDifferenceToSecond()
Calculates the score difference to the second best player in the level.protected int
calculateTargetDirectionRating(Point p)
Returns a positive rating modifier, if p is in the target direction.void
determineItemUsage()
Checks, if the figure wants to use an item it carries around.protected Point
doCalculateNextPoint()
This is called once each round to determine the next point the figure wants to occupy.protected void
doSpecialUpdate(AnimationInfo animation)
This method is called at the end of the regular updateThing()-method.protected static int
getBigMineRadius(Item i)
Gets the radius of a big mine explosion depending on the concrete ItemBigMine-class.int
getIq()
Gets the IQ of this figure.protected int
getPointDangerRating(Point p)
Gets the calculated point danger rating (as determined in last rateField()-call).protected int
getPointRating(Point p, boolean modifyByTargetDirection)
Gets the calculated point rating (as determined in last rateField()-call).protected int
getRegenerationPower()
Calculates, how much energy is gained by regeneraton items.void
handleBigMineDetection(Point pfx, Item i)
Handles a new big mine detection on the field.void
handleRocketDetection(Point pfx, Item i)
Handles a rocket detection on the field.protected boolean
hasBombKit()
Checks, if this figure has a bomb kit.protected boolean
hasCoolGenerator()
Checks, if this figure has a cool generator.protected boolean
hasEnergyTransformer()
Checks, if this figure has an energy transformer.protected boolean
hasFireExtinguisher()
Checks, if this figure has a fire extinguisher.protected boolean
hasFreeSlot()
Checks, if this figure has a fire extinguisher.protected boolean
isAffectedByBlackInternal()
Checks, if this figure is affected by black.protected boolean
isAffectedByDarkRedInternal()
Checks, if this figure is affected by black.protected boolean
isAffectedByGrayInternal()
Checks, if this figure is affected by gray.boolean
isApplyingLevelInfoIQ()
Checks, if level IQ setting should be applied to this figure.protected boolean
isHeatSource(Point p)
Checks, if p is a source of heat.protected boolean
isInLead()
Checks, if this figure is in lead in the current level.protected boolean
isInTargetDirX(Point p)
Checks, if point is in current targets x direction.protected boolean
isInTargetDirY(Point p)
Checks, if point is in current targets y direction.boolean
isPointTooDangerousForHurryingBecauseOfEnergyLoss(Point p)
Checks, if p is dangerous during hurrying due to energy loss.protected boolean
isRamTarget(Figure f)
Checks, if the figure is a good ram target (because it is weaker than this figure).protected boolean
isVisible(Figure f)
Checks, if the figure f is visible to this figure.void
onRoundBegin(AnimationInfo animation)
This method is called at the beginning of each round.protected void
reInit(Field f)
Reinitializes the figure after each level.void
rocketStarted(ItemRocket r, AnimationInfo animation)
Sets the danger flag after a rocket was started.protected void
updateRatingModifiers()
Updates the list of modifiers for detected rockets and big mines.protected boolean
wantsToUseBigMine()
Checks, if a big mine should be used.protected boolean
wantsToUseRocket()
Checks, if a rocket should be used.-
Methods inherited from class com.starpoints.game.ComputerFigure
calculateItemRating, calculateNextPoint, checkEnemy, entersExplosion, findClosestEnemy, getDistance, getDistance, isDummy, isForbiddenItem, isUnwantedItem, modifyByColor, wantsToMove
-
Methods inherited from class com.starpoints.game.Figure
addEnergy, addFigureColorListener, addFigureEnergyListener, addFigureHeatListener, addFigureHoverListener, addFigureItemListener, addFigureKillListener, addFigureMoveListener, addFigurePointListener, addFigureRamListener, addFigureStunListener, addFigureVisibilityListener, addHeat, addInitialEnergy, addLife, addMaxEnergy, addMoney, addPenalty, addPermanentItem, addPoints, addSlots, affectsBlue, beforeMove, beRammed, createState, determineIQ, determineIQ, die, drawState, entersColor, fireColorEnterEvent, fireColorStayEvent, fireDieEvent, fireEnergyChangeEvent, fireEnergyLossEvent, fireGainPermanentItemEvent, fireHeatChangeEvent, fireHoverEvent, fireKillsEnemy, fireLoseItemEvent, fireLosePermanentItemEvent, fireLostPermanentItemEvent, fireMoveEvent, firePickesUpBombEvent, firePickesUpExplosiveEvent, firePickesUpItemEvent, firePointsChangeEvent, firePointSumChangeEvent, fireRamEvent, fireRamPowerEvent, fireSlotsChangeEvent, fireStunEvent, fireUseItemEvent, fireVisibilityChangesEvent, getDieReason, getDyingClip, getExplosionClip, getFreeSlots, getHeatLevel, getHoverHeight, getHoverRounds, getImageName, getInitialEnergy, getInvisibilityRounds, getItem, getKillBonus, getLifes, getMaxSlots, getMoney, getName, getNumber, getPainterClassname, getPermanentItems, getPoints, getPointSum, getRamPower, getSlots, getSpeed, getStunCount, getWinCount, hasMoved, hasPermanentItem, hasPermanentItem, hover, increasePointSum, invulnerable, isAffectedByBlack, isAffectedByGray, isApplyingLevelInfoSpeed, isAvailableInEditor, isDrawingNumber, isHovering, isRocketTarget, isSinking, isStunned, isVisible, loseItem, losePermanentItem, losePermanentItem, losePermanentItemInternal, onAddHeat, onAfterDeath, onBeforeDie, onBeforeRemoveEnergy, onEnemyKilled, onExplode, playDyingSound, removeEnergy, removeFigureColorListener, removeFigureEnergyListener, removeFigureHeatListener, removeFigureHoverListener, removeFigureItemListener, removeFigureKillListener, removeFigureMoveListener, removeFigurePointListener, removeFigureRamListener, removeFigureStunListener, removeFigureVisibilityListener, removeMoney, removePoints, retrieveNextPoint, sellPermanentItem, setHoverCount, setHoverHeight, setInitialEnergy, setInvisible, setIq, setIsRocketTarget, setItem, setMaxEnergy, setMoney, setName, setNumber, setPoint, setSlots, setSpeed, setVisible, sink, staysOnColor, stopHover, stopSink, stun, takeItem, toString, updateExplodingStatus, updatePoints, updateThing, useItem, wantsToUseItem, win
-
Methods inherited from class com.starpoints.game.Thing
addShielding, clearTexts, displayText, displayText, equals, getColor, getEnergy, getEnergyMaxCount, getExplosionCounter, getField, getGame, getID, getInnerColor, getInvulnerableRounds, getLevel, getMaxEnergy, getNextID, getOuterColor, getPoint, getShadowColor, getShield, getStateObject, getStatus, getText, getTextColor, getTextPaintCount, getX, getY, hashCode, isDestroyed, isExploding, isInvulnerable, isOK, isShowingEnergyFx, retrieveState, setEnergy, setEnergyMaxCount, setGame, setStatus, stepText, updateEnergy
-
-
-
-
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 classThing
- 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 classComputerFigure
- Returns:
- The IQ.
-
isApplyingLevelInfoIQ
public boolean isApplyingLevelInfoIQ()
Checks, if level IQ setting should be applied to this figure.- Overrides:
isApplyingLevelInfoIQ
in classComputerFigure
- Returns:
- true.
-
reInit
protected void reInit(Field f)
Reinitializes the figure after each level.
-
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 classComputerFigure
- 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 classFigure
- 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 classComputerFigure
- 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 classComputerFigure
- 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 classComputerFigure
- 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 classComputerFigure
- 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 interfaceFieldListener
- Parameters:
b
- The bigmineanimation
- The AnimationInfo.
-
rocketStarted
public void rocketStarted(ItemRocket r, AnimationInfo animation)
Sets the danger flag after a rocket was started.- Specified by:
rocketStarted
in interfaceFieldListener
- Parameters:
r
- The rocket.animation
- The AnimationInfo.
-
-