Package com.starpoints.game
Class ComputerFigure
- java.lang.Object
-
- com.starpoints.game.Thing
-
- com.starpoints.game.Figure
-
- com.starpoints.game.ComputerFigure
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
BigBoss
,BigBossDuck
,BlueCrawler
,CleverComputerFigure
,CleverComputerFigureMK2
,FlameBall
,KamikazeFigure
,LaserTower
,MrBlack
,SantaClaus
public class ComputerFigure extends Figure
The basic computer figure in the newgame. It acts during game by calculating a rating for each of the 4 points around, and moves to the best one. The point rating is calculated by its color and items on the point. If another figure stands next to this computer figure, it will be rammed, if it has a lower energy level. The figure is displayed as a gray oval.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<Point>
pointList
List of points equally rated at target determination.protected int
speedCount
A counter for the number fo moves to wait until moving on.protected boolean
wantsToEnterBlue
Flag, if this figure currently wants to enter blue points.-
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 ComputerFigure(Game game, FigureInfo f)
Creates a new computer figure on the field.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
calculateItemRating(Item item)
Calculates a rating for the item.protected Point
calculateNextPoint()
Calculates the best next point by checking the currently occupied and its surrounding points.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.protected boolean
checkEnemy(Figure f)
Checks, if a figure is relevant for the closest enemy determination.protected Point
doCalculateNextPoint()
This is called once each round to determine the next point the figure wants to occupy.protected void
doSpecialUpdate(AnimationInfo animation)
Special updates.protected boolean
entersExplosion()
Checks, if this figure wants to enter an explosion.protected Figure
findClosestEnemy()
Searches for the closest enemy figure on the field.protected int
getDistance(Point p)
Gets the distance from this figure to the Point.protected int
getDistance(Point p1, Point p2)
Gets the distance between two points.int
getIq()
Gets the IQ of this figure.boolean
isApplyingLevelInfoIQ()
Checks, if level IQ setting should be applied to this figure.boolean
isDummy()
Checks, if figure is a dummyprotected boolean
isForbiddenItem(Item i)
Checks, if the item is not allowed to be picked up by this figure.protected boolean
isRamTarget(Figure f)
Checks, if the figure is a good ram target (because it is weaker than this figure).protected boolean
isUnwantedItem(Item i)
Checks, if the item is not wanted to be picked up by this figure.protected boolean
isVisible(Figure f)
Checks, if the figure f is visible to this figure.protected int
modifyByColor(Point p, int currentRating)
Modifies the point rating by the points color rating.protected boolean
wantsToMove()
Checks, if this figure wants to move.-
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, onRoundBegin, playDyingSound, reInit, 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, addStateProperties, 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
-
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.
-
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 classFigure
- 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 classFigure
- 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 pointcurrentRating
- 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
-
isApplyingLevelInfoIQ
public boolean isApplyingLevelInfoIQ()
Checks, if level IQ setting should be applied to this figure.- Overrides:
isApplyingLevelInfoIQ
in classFigure
- Returns:
- true.
-
-