All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pinball.player.Strategy

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----pinball.player.Strategy

public class Strategy
extends Thread
Decide whether to flip the flipper or not.


Variable Index

 o boarder
Area around flipper that is to be ignored.
 o buffer
The information buffer.
 o buffinfo
The information from the buffer.
 o firstTime
Used in options to see if the they happened once.
 o flipperHeight
Anything moving below this be considered for flipping.
 o flipperOffset
Where is the flipper from the top of the screen.
 o flipperZone
Y location of begin flipper zone.
 o fromBottom
Location from bottom of screen to be considered out of play.
 o fromTop
Location from top of screen to be considered in play.
 o id
ID of strategy.
 o key
The lock on the strategy.
 o leftDistance
The distance the ball is from the left flipper.
 o leftX
Left flipper x location.
 o leftY
Left flipper y location.
 o middle
The x location for the middle of the flippers.
 o outZone
Location from bottom of screen to be considered out of play.
 o queue
The queue of buffers waiting to be looked at.
 o resetTime
How long can the flipper stay up in the game.
 o rightDistance
The distance the ball is from the right flipper.
 o rightX
Right flipper x location.
 o rightY
Right flipper y location.
 o stub
The stub to connect the strategy to the system.
 o top
Location from bottom of screen to be considered out of play.
 o x
X location of the ball.
 o xsize
Image x size.
 o y
Y location of the ball.
 o ysize
Image y size.

Constructor Index

 o Strategy()
Used in the extended classed.
 o Strategy(Buffer, TextArea, Camera)
Make a new strategy thread.

Method Index

 o bufferAvailable()
Notify the thread that a buffer is available.
 o custom()
Allow extended classes to define a custom startup option.
 o decision()
Should you flip or not.
 o draw(Graphics, int, int)
Allows the strategy to draw to the screen any lines or other graphics for the user to see how the strategy operates.
 o flipperFlipped(boolean)
Set the flippers flipped condition.
 o flippersCheck()
Check if the flippers need to be reset and then decide if they need to be flipped.
 o flippersReset()
Reset the flippers if they are up the allowed amount of time.
 o getStub()
Get the stub from the strategy.
 o getStubInfo()
Get info from the stub.
 o halt()
Halt the thread until the queue is not empty.
 o id()
Get the id of the strategy.
 o initalize()
Initalize the strategy.
 o option()
Setup the options for the strategy.
 o resetTime(int)
Get the flipper reset time.
 o run()
Wait until the stub filtered out the ball and then decide to flip or not.
 o setQueue(StrategyQueue)
Set up the queue of buffers.
 o special()
Special is used for players that want to add something special to their strategy, but want the standard decision.
 o testing()
Used to simulate lots packets.
 o toString()
Get the name of the object.

Variables

 o x
 protected int x
X location of the ball.

 o y
 protected int y
Y location of the ball.

 o xsize
 protected int xsize
Image x size.

 o ysize
 protected int ysize
Image y size.

 o leftX
 protected int leftX
Left flipper x location.

 o leftY
 protected int leftY
Left flipper y location.

 o rightX
 protected int rightX
Right flipper x location.

 o rightY
 protected int rightY
Right flipper y location.

 o boarder
 protected int boarder
Area around flipper that is to be ignored.

 o flipperOffset
 protected int flipperOffset
Where is the flipper from the top of the screen.

 o resetTime
 protected int resetTime
How long can the flipper stay up in the game.

 o flipperZone
 protected int flipperZone
Y location of begin flipper zone.

 o firstTime
 protected boolean firstTime
Used in options to see if the they happened once.

 o fromTop
 protected int fromTop
Location from top of screen to be considered in play.

 o fromBottom
 protected int fromBottom
Location from bottom of screen to be considered out of play.

 o flipperHeight
 protected int flipperHeight
Anything moving below this be considered for flipping.

 o top
 protected int top
Location from bottom of screen to be considered out of play. Gets value from fromTop.

 o outZone
 protected int outZone
Location from bottom of screen to be considered out of play. Gets value from fromBottom.

 o buffer
 protected Buffer buffer
The information buffer.

 o buffinfo
 protected BufferInfo buffinfo
The information from the buffer.

 o id
 protected String id
ID of strategy.

 o stub
 protected Stub stub
The stub to connect the strategy to the system.

 o key
 protected boolean key
The lock on the strategy.

 o queue
 protected StrategyQueue queue
The queue of buffers waiting to be looked at.

 o leftDistance
 protected int leftDistance
The distance the ball is from the left flipper.

 o rightDistance
 protected int rightDistance
The distance the ball is from the right flipper.

 o middle
 protected int middle
The x location for the middle of the flippers.

Constructors

 o Strategy
 public Strategy(Buffer buffer,
                 TextArea gameStats,
                 Camera camera)
Make a new strategy thread.

Parameters:
buffer - the first buffer in the series of buffer.
gameStats - the area to write the game stats info.
camera - the camera for the system.
 o Strategy
 public Strategy()
Used in the extended classed.

Methods

 o toString
 public String toString()
Get the name of the object.

Parameters:
name - of the object.
Overrides:
toString in class Thread
 o id
 public String id()
Get the id of the strategy.

Returns:
id of strategy.
 o custom
 public void custom()
Allow extended classes to define a custom startup option.

 o run
 public void run()
Wait until the stub filtered out the ball and then decide to flip or not.

Overrides:
run in class Thread
 o halt
 public synchronized void halt()
Halt the thread until the queue is not empty.

 o bufferAvailable
 public synchronized void bufferAvailable()
Notify the thread that a buffer is available.

 o setQueue
 public void setQueue(StrategyQueue q)
Set up the queue of buffers.

Parameters:
q - the queue of buffers.
 o testing
 public boolean testing()
Used to simulate lots packets. This will randomly release the lock.

 o initalize
 public void initalize()
Initalize the strategy. Finds the flippers.

 o getStub
 public Stub getStub()
Get the stub from the strategy.

 o getStubInfo
 public void getStubInfo()
Get info from the stub. The flipper locations, and flipper zone info.

 o resetTime
 public void resetTime(int reset)
Get the flipper reset time.

Parameters:
reset - the reset time.
 o flippersReset
 public void flippersReset()
Reset the flippers if they are up the allowed amount of time.

 o flipperFlipped
 public void flipperFlipped(boolean status)
Set the flippers flipped condition.

Parameters:
status - the flippers flipped status.
 o flippersCheck
 public void flippersCheck()
Check if the flippers need to be reset and then decide if they need to be flipped.

 o option
 public void option()
Setup the options for the strategy. This one sets the in play area and flipper height.

 o decision
 public void decision()
Should you flip or not.

 o special
 public void special()
Special is used for players that want to add something special to their strategy, but want the standard decision.

 o draw
 public void draw(Graphics g,
                  int canvasWidth,
                  int canvasHeight)
Allows the strategy to draw to the screen any lines or other graphics for the user to see how the strategy operates.

Parameters:
g - the graphics area to draw to.
canvasWidth - the width of the canvas.
canvasHeight - the height of the canvas.

All Packages  Class Hierarchy  This Package  Previous  Next  Index