ballwar.model.strategy
Class WanderStrategy
java.lang.Object
ballwar.model.strategy.ANoOpStrategy
ballwar.model.strategy.WanderStrategy
- All Implemented Interfaces:
- IUpdateStrategy
public class WanderStrategy
- extends ANoOpStrategy
An ANoOpStrategy-based strategy that randomly modifies the velocity whenever the state of the context is updated.
Field Summary |
private int |
_delta
The maximum absolute value of any of the velocity increment's coordinates. |
private IRandomizer |
_rand
The Randomizer used to generate the random velocity increment vector's coordinates. |
Method Summary |
void |
updateState(Ball context)
Adds a random vector value to the context's velocity. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_rand
private IRandomizer _rand
- The Randomizer used to generate the random velocity increment vector's coordinates.
_delta
private int _delta
- The maximum absolute value of any of the velocity increment's coordinates.
WanderStrategy
public WanderStrategy()
updateState
public void updateState(Ball context)
- Adds a random vector value to the context's velocity. The coordinates of the random
vector each have an absolute value less than or equal to a stored maximum.
- Specified by:
updateState
in interface IUpdateStrategy
- Overrides:
updateState
in class ANoOpStrategy
- Parameters:
context
- The context for this strategy.