예제 #1
0
 private void stopBall(PlayerInterface player) {
   // This would be a condition where it would be sensible to stop the ball
   // if(player.Ball().Velocity().LengthSq()>Prm.holdingBallSpeed){
   System.out.println("Trying to stop the ball!");
   Vector2D randomSmallVector = new Vector2D(Utilities.RandomClamped(), Utilities.RandomClamped());
   // The illusion of stopping the ball
   if (player.isReadyForNextKick()) {
     player.Ball().setPos(randomSmallVector.add(player.Pos()));
     Vector2D BallTarget = player.Ball().Pos().addToCopy(player.Ball().Velocity());
     player.Kick(BallTarget, Prm.StoppingForce);
   } else {
     System.err.println(
         "RL Version of stop ball was called when agent was not ready for kick, shouldn't happen");
   }
   // change state
   player.GetFSM().changeState(ChaseBall.Instance());
 }
예제 #2
0
  // ----------------------------- AddNoiseToKick --------------------------------
  //
  //  this can be used to vary the accuracy of a player's kick. Just call it
  //  prior to kicking the ball using the ball's position and the ball target as
  //  parameters.
  // -----------------------------------------------------------------------------
  Vector2D AddNoiseToKick(Vector2D BallPos, Vector2D BallTarget) {

    double displacement =
        (Math.PI - Math.PI * Prm.PlayerKickingAccuracy) * Utilities.RandomClamped();

    Vector2D toTarget = BallTarget.subtractToCopy(BallPos);
    toTarget.RotateAroundOrigin(displacement);

    return toTarget.add(BallPos);
  }