|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.aiEngine.pongAI.PongAIMemory
public class PongAIMemory
PongAIMemory.java
Constructor Summary | |
---|---|
PongAIMemory()
A basic constructor that initializes everything so that the program doesn't throw nullpointerexceptions. |
Method Summary | |
---|---|
void |
addtoMemory(Position a)
Adds the new position of the tracked object into a list, and makes the list behave like a queue, while allowing for the computer to see elements at many different points along the queue without popping things out and in all the time. |
Position |
findbestPositionfrommemory()
Just reads out the current running best position is from the average position of previous collisions. |
Position |
getCurrentvelocity()
Draws from memory to calculate the current velocity. |
Position |
getPreviousvelocity()
Draws from memory to calculate a velocity prior to the current calculated velocity. |
boolean |
memoryhasdata()
A simple check to see whether or not the AI has gathered enough data to carry out operations like projection. |
Position |
project(Position aiPos,
Position targetPos,
Position currentvelocity,
int boardwidth)
Projects the position at which the ball will reach the ai by calculating the total distance the ball will move in the y-direction in proportion to its movement in the x-direction and then counts how many times the ball would bounce off either side of the board to determine the final y-position once it reaches the x-position of the ai's paddle. |
void |
remembercollision(Position b)
Adds a new collision position to a running average. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PongAIMemory()
Method Detail |
---|
public void addtoMemory(Position a)
a
- - A new position to be registered.public void remembercollision(Position b)
b
- - A new collision position to be factored in to the running
average.public boolean memoryhasdata()
public Position getPreviousvelocity()
public Position getCurrentvelocity()
public Position project(Position aiPos, Position targetPos, Position currentvelocity, int boardwidth)
aiPos
- - Current position of the aitargetPos
- - Current position of the ballcurrentvelocity
- - Most recent change in position of the ballboardwidth
- - The width of the board, for use in calculating the number of
times the ball will bounce of the sides of the board.
public Position findbestPositionfrommemory()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |