jfreerails.controller
Class MoveTrainPreMove
java.lang.Object
jfreerails.controller.MoveTrainPreMove
- All Implemented Interfaces:
- java.io.Serializable, PreMove, FreerailsSerializable
public class MoveTrainPreMove
- extends java.lang.Object
- implements PreMove
Generates moves for changes in train position and stops at stations.
- Author:
- Luke
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
logger
private static final java.util.logging.Logger logger
principal
private final FreerailsPrincipal principal
trainID
private final int trainID
MoveTrainPreMove
public MoveTrainPreMove(int id,
FreerailsPrincipal p)
findNextStep
public static Step findNextStep(ReadOnlyWorld world,
PositionOnTrack currentPosition,
ImPoint target)
- Uses static method to make testing easier.
acceleration
double acceleration(int wagons)
isUpdateDue
public boolean isUpdateDue(ReadOnlyWorld w)
- Returns true iff an updated is due.
currentTrainTarget
private ImPoint currentTrainTarget(ReadOnlyWorld w)
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in class java.lang.Object
generateMove
public Move generateMove(ReadOnlyWorld w)
- Specified by:
generateMove
in interface PreMove
getActivity
public SpeedTimeAndStatus.TrainActivity getActivity(ReadOnlyWorld w)
hashCode
public int hashCode()
- Overrides:
hashCode
in class java.lang.Object
lastMotion
private TrainMotion lastMotion(ReadOnlyWorld w)
moveTrain
private Move moveTrain(ReadOnlyWorld w)
occupiedTrackSections
private java.util.HashMap<TrackSection,java.lang.Integer> occupiedTrackSections(ReadOnlyWorld w)
nextMotion
TrainMotion nextMotion(ReadOnlyWorld w,
Step v)
nextSpeeds
SpeedAgainstTime nextSpeeds(ReadOnlyWorld w,
Step v)
nextStep
Step nextStep(ReadOnlyWorld w)
stopTrain
public Move stopTrain(ReadOnlyWorld w)
topSpeed
double topSpeed(int wagons)