fi.utu.cs.hockey.ai
Class AI

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--fi.utu.cs.hockey.net.Client
              |
              +--fi.utu.cs.hockey.ai.AI
All Implemented Interfaces:
Communication, Position, java.lang.Runnable

public abstract class AI
extends Client

AI for a hockey player.


Nested Class Summary
static class AI.PlayerIterator
          A class for iterating player positions.
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface fi.utu.cs.hockey.net.Communication
CENTER_SPOT, HEADING_ANGLE, NO_FACEOFF, OUR_ENDZONE_LEFT, OUR_ENDZONE_RIGHT, OUR_NEUTRAL_ZONE_LEFT, OUR_NEUTRAL_ZONE_RIGHT, THEIR_ENDZONE_LEFT, THEIR_ENDZONE_RIGHT, THEIR_NEUTRAL_ZONE_LEFT, THEIR_NEUTRAL_ZONE_RIGHT, X_COORDINATE, Y_COORDINATE
 
Fields inherited from interface fi.utu.cs.hockey.Position
CENTER, GOALKEEPER, LEFT_DEFENSE, LEFT_WING, RIGHT_DEFENSE, RIGHT_WING
 
Constructor Summary
protected AI()
          Creates a player AI
protected AI(java.lang.String s, java.lang.String t, int n, int p, java.awt.Color h, java.awt.Color j)
          Creates a player AI with name s, team name t, number n, position p, helmet color h, and jersey color j.
 
Method Summary
 double headingTo(double[] p)
          Returns the angle of heading to the point (p[X_COORDINATE], p[Y_COORDINATE]) from the player's current location.
 double headingTo(double x, double y)
          Returns the angle of heading to the point (x, y) from the player's current location.
 boolean isPuckWithinReach()
          Returns true if the puck is within the reach of the player.
 AI.PlayerIterator iteratorAll()
          Returns an iterator for all player positions.
 AI.PlayerIterator iteratorDefense()
          Returns an iterator for defense positions.
 AI.PlayerIterator iteratorForward()
          Returns an iterator for forward positions.
protected abstract  void react()
          Reacts to the game events.
 void run()
          Calls repeatedly the react method.
 
Methods inherited from class fi.utu.cs.hockey.net.Client
brake, connect, dash, faceoff, finalize, getHelmetColor, getJerseyColor, getNumber, getPlayerName, getPosition, getTeamName, head, isFoul, isGameOver, isGameStopped, isGoal, isGoalieKeepingPuck, isIcing, isInHomeTeam, isInterferingGoalie, isJoined, isOffside, isPuckUnplayable, keepPuck, messages, player, puck, say, score, setHelmetColor, setJerseyColor, setNumber, setPlayerName, setPosition, setTeamName, shoot, time
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AI

protected AI()
Creates a player AI


AI

protected AI(java.lang.String s,
             java.lang.String t,
             int n,
             int p,
             java.awt.Color h,
             java.awt.Color j)
Creates a player AI with name s, team name t, number n, position p, helmet color h, and jersey color j.

Method Detail

run

public final void run()
Calls repeatedly the react method.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

react

protected abstract void react()
Reacts to the game events. This method connects the player AI to the game engine.


isPuckWithinReach

public boolean isPuckWithinReach()
Returns true if the puck is within the reach of the player.


headingTo

public double headingTo(double x,
                        double y)
Returns the angle of heading to the point (x, y) from the player's current location.

See Also:
Communication.head(double)

headingTo

public double headingTo(double[] p)
Returns the angle of heading to the point (p[X_COORDINATE], p[Y_COORDINATE]) from the player's current location.

See Also:
Communication.head(double), Communication.X_COORDINATE, Communication.Y_COORDINATE

iteratorAll

public AI.PlayerIterator iteratorAll()
Returns an iterator for all player positions.


iteratorDefense

public AI.PlayerIterator iteratorDefense()
Returns an iterator for defense positions.


iteratorForward

public AI.PlayerIterator iteratorForward()
Returns an iterator for forward positions.