wyvern.lib.ai
Class BeelineAI

java.lang.Object
  extended byjava.lang.Thread
      extended bywyvern.kernel.commands.AbstractAI
          extended bywyvern.lib.ai.BeelineAI
All Implemented Interfaces:
AI, java.lang.Runnable

public class BeelineAI
extends AbstractAI

Makes hostile monsters attack the nearest player, without checking for walls or obstructions. A fairly useless AI unless the monster is in a map where there are no obstructions, in which case it's much more efficient than the StandardAI.

Version:
1.0, Apr 19, 1998
Author:
Steve Yegge

Field Summary
 
Fields inherited from class wyvern.kernel.commands.AbstractAI
commandables_, commandList_, queues_
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface wyvern.lib.AI
DEFAULT_MONSTER_INERTIA, DEFAULT_WANDER_RANGE
 
Constructor Summary
protected BeelineAI(java.lang.String name)
           
 
Method Summary
static AI add(Commandable m)
          Puts a monster under this AI's control.
 Player findClosestPlayer(Point loc1, java.util.Set players)
          Finds the most desirable player to attack, using the simple logic "closer is better".
static AI getImpl()
           
 void moveRandomly(Commandable agent, EventQueue q)
          Moves the commandable in a random direction.
static void remove(Commandable m)
          Removes a monster from our control.
 void think(Commandable agent, EventQueue q)
          Decide what to do next.
 
Methods inherited from class wyvern.kernel.commands.AbstractAI
addCommandable, addToHateList, chooseRandomDir, getAverageTime, getCommand, getNumThinks, getProfilingInfo, getTotalTime, isControlling, moveRandomly, notifyAttacked, registerCommand, removeCommandable, requestEvent, run, serviceQueues, thinkForQueue, unregisterCommand
 
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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeelineAI

protected BeelineAI(java.lang.String name)
Method Detail

getImpl

public static AI getImpl()

add

public static AI add(Commandable m)
Puts a monster under this AI's control.

Parameters:
m - a monster to add
Returns:
the AI instance that the monster was added to

remove

public static void remove(Commandable m)
Removes a monster from our control.

Parameters:
m - the monster to add

think

public void think(Commandable agent,
                  EventQueue q)
Decide what to do next. Called by superclass when q is ready.

Specified by:
think in interface AI
Specified by:
think in class AbstractAI
Parameters:
agent - the commandable to think for
q - the commandable's event queue

findClosestPlayer

public Player findClosestPlayer(Point loc1,
                                java.util.Set players)
Finds the most desirable player to attack, using the simple logic "closer is better".

Parameters:
loc1 - the location of the monster that's looking
players - the set of players in the current map
Returns:
the Player we like best, or null if none was found

moveRandomly

public void moveRandomly(Commandable agent,
                         EventQueue q)
Moves the commandable in a random direction.