bhv_set_play_indirect_free_kick.cpp 21.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
// -*-c++-*-

/*
 *Copyright:

 Copyright (C) Hidehisa AKIYAMA

 This code is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3, or (at your option)
 any later version.

 This code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this code; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

 *EndCopyright:
 */

/////////////////////////////////////////////////////////////////////

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "bhv_set_play_indirect_free_kick.h"

#include "strategy.h"

#include "bhv_set_play.h"
#include "bhv_prepare_set_play_kick.h"
#include "bhv_go_to_static_ball.h"
#include "bhv_chain_action.h"

#include "intention_wait_after_set_play_kick.h"

#include <rcsc/action/basic_actions.h>
#include <rcsc/action/body_go_to_point.h>
#include <rcsc/action/body_kick_one_step.h>
#include <rcsc/action/body_kick_collide_with_ball.h>
#include <rcsc/action/body_pass.h>
#include <rcsc/action/neck_scan_field.h>
#include <rcsc/action/neck_turn_to_ball_or_scan.h>

#include <rcsc/player/player_agent.h>
#include <rcsc/player/debug_client.h>
#include <rcsc/player/say_message_builder.h>

#include <rcsc/common/logger.h>
#include <rcsc/common/server_param.h>
#include <rcsc/geom/circle_2d.h>
#include <rcsc/math_util.h>

using namespace rcsc;

/*-------------------------------------------------------------------*/
/*!

 */
bool
Bhv_SetPlayIndirectFreeKick::execute( PlayerAgent * agent )
{
    const WorldModel & wm = agent->world();

    const bool our_kick = ( ( wm.gameMode().type() == GameMode::BackPass_
                              && wm.gameMode().side() == wm.theirSide() )
                            || ( wm.gameMode().type() == GameMode::IndFreeKick_
                                 && wm.gameMode().side() == wm.ourSide() )
                            || ( wm.gameMode().type() == GameMode::FoulCharge_
                                 && wm.gameMode().side() == wm.theirSide() )
                            || ( wm.gameMode().type() == GameMode::FoulPush_
                                 && wm.gameMode().side() == wm.theirSide() )
                            );

    if ( our_kick )
    {
        dlog.addText( Logger::TEAM,
                      __FILE__": (execute) our kick" );

        if ( Bhv_SetPlay::is_kicker( agent ) )
        {
            doKicker( agent );
        }
        else
        {
            doOffenseMove( agent );
        }
    }
    else
    {
        dlog.addText( Logger::TEAM,
                      __FILE__": (execute) their kick" );

        doDefenseMove( agent );
    }

    return true;
}

/*-------------------------------------------------------------------*/
/*!

 */
void
Bhv_SetPlayIndirectFreeKick::doKicker( PlayerAgent * agent )
{
    // go to ball
    if ( Bhv_GoToStaticBall( 0.0 ).execute( agent ) )
    {
        return;
    }

    //
    // wait
    //

    if ( doKickWait( agent ) )
    {
        return;
    }

    //
    // kick to the teammate exist at the front of their goal
    //

    if ( doKickToShooter( agent ) )
    {
        return;
    }

    const WorldModel & wm = agent->world();

    const double max_kick_speed = wm.self().kickRate() * ServerParam::i().maxPower();

    //
    // pass
    //
    if ( Bhv_ChainAction().execute( agent ) )
    {
        agent->setIntention( new IntentionWaitAfterSetPlayKick() );
        return;
    }
    // {
    //     const double max_kick_speed = wm.self().kickRate() * ServerParam::i().maxPower();
    //     Vector2D target_point;
    //     double ball_speed = 0.0;
    //     if  ( Body_Pass::get_best_pass( wm,
    //                                     &target_point,
    //                                     &ball_speed,
    //                                     NULL )
    //           && target_point.x > 35.0
    //           && ( target_point.x > wm.self().pos().x - 1.0
    //                || target_point.x > 48.0 ) )
    //     {
    //         ball_speed = std::min( ball_speed, max_kick_speed );
    //         dlog.addText( Logger::TEAM,
    //                       __FILE__":  pass to (%.1f %.1f) speed=%.2f",
    //                       target_point.x, target_point.y,
    //                       ball_speed );
    //         Body_KickOneStep( target_point, ball_speed ).execute( agent );
    //         agent->setNeckAction( new Neck_ScanField() );
    //         return;
    //     }
    // }

    //
    // wait(2)
    //
    if ( wm.setplayCount() <= 3 )
    {
        Body_TurnToPoint( Vector2D( 50.0, 0.0 ) ).execute( agent );
        agent->setNeckAction( new Neck_ScanField() );
        return;
    }

    //
    // no teammate
    //
    if ( wm.teammatesFromBall().empty()
         || wm.teammatesFromBall().front()->distFromSelf() > 35.0
         || wm.teammatesFromBall().front()->pos().x < -30.0 )
    {
        const int real_set_play_count
            = static_cast< int >( wm.time().cycle() - wm.lastSetPlayStartTime().cycle() );

        if ( real_set_play_count <= ServerParam::i().dropBallTime() - 3 )
        {
            dlog.addText( Logger::TEAM,
                          __FILE__": (doKick) real set play count = %d <= drop_time-3, wait...",
                          real_set_play_count );
            Body_TurnToPoint( Vector2D( 50.0, 0.0 ) ).execute( agent );
            agent->setNeckAction( new Neck_ScanField() );
            return;
        }

        Vector2D target_point( ServerParam::i().pitchHalfLength(),
                               static_cast< double >( -1 + 2 * wm.time().cycle() % 2 )
                               * ( ServerParam::i().goalHalfWidth() - 0.8 ) );
        double ball_speed = max_kick_speed;

        agent->debugClient().addMessage( "IndKick:ForceShoot" );
        agent->debugClient().setTarget( target_point );
        dlog.addText( Logger::TEAM,
                      __FILE__":  kick to goal (%.1f %.1f) speed=%.2f",
                      target_point.x, target_point.y,
                      ball_speed );

        Body_KickOneStep( target_point, ball_speed ).execute( agent );
        agent->setNeckAction( new Neck_ScanField() );
        return;
    }

    //
    // kick to the teammate nearest to opponent goal
    //

    const Vector2D goal( ServerParam::i().pitchHalfLength(),
                         wm.self().pos().y * 0.8 );

    double min_dist = 100000.0;
    const PlayerObject * receiver = static_cast< const PlayerObject * >( 0 );

    const PlayerPtrCont::const_iterator t_end = wm.teammatesFromBall().end();
    for ( PlayerPtrCont::const_iterator t = wm.teammatesFromBall().begin();
          t != t_end;
          ++t )
    {
        if ( (*t)->posCount() > 5 ) continue;
        if ( (*t)->distFromBall() < 1.5 ) continue;
        if ( (*t)->distFromBall() > 20.0 ) continue;
        if ( (*t)->pos().x > wm.offsideLineX() ) continue;

        double dist = (*t)->pos().dist( goal ) + (*t)->distFromBall();
        if ( dist < min_dist )
        {
            min_dist = dist;
            receiver = (*t);
        }
    }

    Vector2D target_point = goal;
    double target_dist = 10.0;
    if ( ! receiver )
    {
        target_dist = wm.teammatesFromSelf().front()->distFromSelf();
        target_point = wm.teammatesFromSelf().front()->pos();
    }
    else
    {
        target_dist = receiver->distFromSelf();
        target_point = receiver->pos();
        target_point.x += 0.6;
    }

    double ball_speed = calc_first_term_geom_series_last( 1.8, // end speed
                                                          target_dist,
                                                          ServerParam::i().ballDecay() );
    ball_speed = std::min( ball_speed, max_kick_speed );

    agent->debugClient().addMessage( "IndKick:ForcePass%.3f", ball_speed );
    agent->debugClient().setTarget( target_point );
    dlog.addText( Logger::TEAM,
                  __FILE__":  pass to nearest teammate (%.1f %.1f) speed=%.2f",
                  target_point.x, target_point.y,
                  ball_speed );


    Body_KickOneStep( target_point, ball_speed ).execute( agent );
    agent->setNeckAction( new Neck_ScanField() );
    agent->addSayMessage( new BallMessage( agent->effector().queuedNextBallPos(),
                                           agent->effector().queuedNextBallVel() ) );
}

/*-------------------------------------------------------------------*/
/*!

 */
bool
Bhv_SetPlayIndirectFreeKick::doKickWait( PlayerAgent * agent )
{
    const WorldModel & wm = agent->world();

    const Vector2D face_point( 50.0, 0.0 );
    const AngleDeg face_angle = ( face_point - wm.self().pos() ).th();

    //     if ( wm.setplayCount() <= 3 )
    //     {
    //         Body_TurnToPoint( face_point ).execute( agent );
    //         agent->setNeckAction( new Neck_ScanField() );
    //         return;
    //     }

    if ( wm.time().stopped() > 0 )
    {
        dlog.addText( Logger::TEAM,
                      __FILE__": (doKickWait) stoppage time" );

        Body_TurnToPoint( face_point ).execute( agent );
        agent->setNeckAction( new Neck_ScanField() );
        return true;
    }

    if ( ( face_angle - wm.self().body() ).abs() > 5.0 )
    {
        dlog.addText( Logger::TEAM,
                      __FILE__": (doKickWait) turn to the front of goal" );

        agent->debugClient().addMessage( "IndKick:TurnTo" );
        agent->debugClient().setTarget( face_point );

        Body_TurnToPoint( face_point ).execute( agent );
        agent->setNeckAction( new Neck_ScanField() );
        return true;
    }

    if ( wm.setplayCount() <= 10
         && wm.teammatesFromSelf().empty() )
    {
        dlog.addText( Logger::TEAM,
                      __FILE__": (doKickWait) no teammate" );

        agent->debugClient().addMessage( "IndKick:NoTeammate" );
        agent->debugClient().setTarget( face_point );

        Body_TurnToPoint( face_point ).execute( agent );
        agent->setNeckAction( new Neck_ScanField() );
        return true;
    }

    return false;
}

/*-------------------------------------------------------------------*/
/*!

 */
bool
Bhv_SetPlayIndirectFreeKick::doKickToShooter( PlayerAgent * agent )
{
    const WorldModel & wm = agent->world();


    const Vector2D goal( ServerParam::i().pitchHalfLength(),
                         wm.self().pos().y * 0.8 );

    double min_dist = 100000.0;
    const PlayerObject * receiver = static_cast< const PlayerObject * >( 0 );

    const PlayerPtrCont::const_iterator t_end = wm.teammatesFromBall().end();
    for ( PlayerPtrCont::const_iterator t = wm.teammatesFromBall().begin();
          t != t_end;
          ++t )
    {
        if ( (*t)->posCount() > 5 ) continue;
        //if ( (*t)->distFromBall() < 1.5 ) continue;
        if ( (*t)->distFromBall() > 20.0 ) continue;
        if ( (*t)->pos().x > wm.offsideLineX() ) continue;
        if ( (*t)->pos().x < wm.ball().pos().x - 3.0 ) continue;
        //if ( (*t)->pos().absY() > ServerParam::i().goalHalfWidth() * 0.5 ) continue;

        double goal_dist = (*t)->pos().dist( goal );
        if ( goal_dist > 16.0 )
        {
            continue;
        }

        double dist = goal_dist * 0.4 + (*t)->distFromBall() * 0.6;

        if ( dist < min_dist )
        {
            min_dist = dist;
            receiver = (*t);
        }
    }

    if ( ! receiver )
    {
        dlog.addText( Logger::TEAM,
                      __FILE__": (doKicToShooter) no shooter" );
        return false;
    }

    const double max_ball_speed = wm.self().kickRate() * ServerParam::i().maxPower();

    Vector2D target_point = receiver->pos() + receiver->vel();
    target_point.x += 0.6;

    double target_dist = wm.ball().pos().dist( target_point );

    int ball_reach_step
        = static_cast< int >( std::ceil( calc_length_geom_series( max_ball_speed,
                                                                  target_dist,
                                                                  ServerParam::i().ballDecay() ) ) );
    double ball_speed = calc_first_term_geom_series( target_dist,
                                                     ServerParam::i().ballDecay(),
                                                     ball_reach_step );

    ball_speed = std::min( ball_speed, max_ball_speed );

    agent->debugClient().addMessage( "IndKick:KickToShooter%.3f", ball_speed );
    agent->debugClient().setTarget( target_point );
    dlog.addText( Logger::TEAM,
                  __FILE__":  pass to nearest teammate (%.1f %.1f) ball_speed=%.2f reach_step=%d",
                  target_point.x, target_point.y,
                  ball_speed, ball_reach_step );

    Body_KickOneStep( target_point, ball_speed ).execute( agent );
    agent->setNeckAction( new Neck_ScanField() );

    return true;

}

namespace {

Vector2D
get_avoid_circle_point( const WorldModel & wm,
                        Vector2D point )
{
    const ServerParam & SP = ServerParam::i();

    const double circle_r
        = wm.gameMode().type() == GameMode::BackPass_
        ? SP.goalAreaLength() + 0.5
        : SP.centerCircleR() + 0.5;
    const double circle_r2 = std::pow( circle_r, 2 );

    dlog.addText( Logger::TEAM,
                  __FILE__": (get_avoid_circle_point) point=(%.1f %.1f)",
                  point.x, point.y );


    if ( point.x < -SP.pitchHalfLength() + 3.0
         && point.absY() < SP.goalHalfWidth() )
    {
        while ( point.x < wm.ball().pos().x
                && point.x > - SP.pitchHalfLength()
                && wm.ball().pos().dist2( point ) < circle_r2 )
        {
            //point.x -= 0.2;
            point.x = ( point.x - SP.pitchHalfLength() ) * 0.5 - 0.01;
            dlog.addText( Logger::TEAM,
                          __FILE__": adjust x (%.1f %.1f)",
                          point.x, point.y );
        }
    }

    if ( point.x < -SP.pitchHalfLength() + 0.5
         && point.absY() < SP.goalHalfWidth() + 0.5
         && wm.self().pos().x < -SP.pitchHalfLength()
         && wm.self().pos().absY() < SP.goalHalfWidth() )
    {
        dlog.addText( Logger::TEAM,
                      __FILE__": (get_avoid_circle_point) ok. already in our goal",
                      point.x, point.y );
        return point;
    }

    if ( wm.ball().pos().dist2( point ) < circle_r2 )
    {
        Vector2D rel = point - wm.ball().pos();
        rel.setLength( circle_r );
        point = wm.ball().pos() + rel;

        dlog.addText( Logger::TEAM,
                      __FILE__": (get_avoid_circle_point) circle contains target. adjusted=(%.2f %.2f)",
                      point.x, point.y );
    }

    // if ( wm.ball().pos().x - circle_r < point.x
    //      && point.x < wm.ball().pos().x
    //      && wm.ball().pos().dist2( point ) < circle_r2 )
    // {
    //     if ( wm.self().pos().x < - SP.pitchHalfLength() + 0.1
    //          && wm.self().pos().absY() < SP.goalHalfWidth() - 0.5 )
    //     {
    //         dlog.addText( Logger::TEAM,
    //                       __FILE__": can go to the point directly." );
    //         return point;
    //     }
    //     if ( wm.self().pos().x < wm.ball().pos().x - circle_r )
    //     {
    //         dlog.addText( Logger::TEAM,
    //                       __FILE__": can go to the Y. my_pos.x=%.1f < ball_x-r=%f",
    //                       wm.self().pos().x,
    //                       wm.ball().pos().x - circle_r );
    //         return Vector2D( wm.self().pos().x, point.y );
    //     }
    //     Vector2D tmp_point( wm.ball().pos().x - circle_r, point.y );
    //     dlog.addText( Logger::TEAM,
    //                   __FILE__": modified recursive. tmp_point=(%.1f %.1f)",
    //                   tmp_point.x, tmp_point.y );
    //     return get_avoid_circle_point( wm, tmp_point );
    // }


    return Bhv_SetPlay::get_avoid_circle_point( wm, point );
}

} // end noname namespace

/*-------------------------------------------------------------------*/
/*!

 */
void
Bhv_SetPlayIndirectFreeKick::doOffenseMove( PlayerAgent * agent )
{
    const WorldModel & wm = agent->world();

    Vector2D target_point = Strategy::i().getPosition( wm.self().unum() );
    target_point.x = std::min( wm.offsideLineX() - 1.0, target_point.x );

    double nearest_dist = 1000.0;
    const PlayerObject * teammate = wm.getTeammateNearestTo( target_point, 10, &nearest_dist );
    if ( nearest_dist < 2.5 )
    {
        target_point += ( target_point - teammate->pos() ).setLengthVector( 2.5 );
        target_point.x = std::min( wm.offsideLineX() - 1.0, target_point.x );
    }

    double dash_power = wm.self().getSafetyDashPower( ServerParam::i().maxDashPower() );

    double dist_thr = wm.ball().distFromSelf() * 0.07;
    if ( dist_thr < 0.5 ) dist_thr = 0.5;

    agent->debugClient().addMessage( "IndFK:OffenseMove" );
    agent->debugClient().setTarget( target_point );
    agent->debugClient().addCircle( target_point, dist_thr );

    if ( ! Body_GoToPoint( target_point,
                           dist_thr,
                           dash_power
                           ).execute( agent ) )
    {
        // already there
        Vector2D turn_point
            = ( ServerParam::i().theirTeamGoalPos() + wm.ball().pos() ) * 0.5;

        Body_TurnToPoint( turn_point ).execute( agent );
        dlog.addText( Logger::TEAM,
                      __FILE__":  our kick. turn to (%.1f %.1f)",
                      turn_point.x, turn_point.y );
    }

    if ( target_point.x > 36.0
         && ( wm.self().pos().dist( target_point )
              > std::max( wm.ball().pos().dist( target_point ) * 0.2, dist_thr ) + 6.0
              || wm.self().stamina() < ServerParam::i().staminaMax() * 0.7 )
         )
    {
        if ( ! wm.self().staminaModel().capacityIsEmpty() )
        {
            agent->debugClient().addMessage( "Sayw" );
            agent->addSayMessage( new WaitRequestMessage() );
        }
    }

    agent->setNeckAction( new Neck_TurnToBallOrScan() );
}

/*-------------------------------------------------------------------*/
/*!

 */
void
Bhv_SetPlayIndirectFreeKick::doDefenseMove( PlayerAgent * agent )
{
    const ServerParam & SP = ServerParam::i();
    const WorldModel & wm = agent->world();

    Vector2D target_point = Strategy::i().getPosition( wm.self().unum() );
    Vector2D adjusted_point = get_avoid_circle_point( wm, target_point );

    dlog.addText( Logger::TEAM,
                  __FILE__": their kick adjust target to (%.1f %.1f)->(%.1f %.1f) ",
                  target_point.x, target_point.y,
                  adjusted_point.x, adjusted_point.y );

    double dash_power = wm.self().getSafetyDashPower( SP.maxDashPower() );

    double dist_thr = wm.ball().distFromSelf() * 0.07;
    if ( dist_thr < 0.5 ) dist_thr = 0.5;

    if ( adjusted_point != target_point
         && wm.ball().pos().dist( target_point ) > 10.0
         && wm.self().inertiaFinalPoint().dist( adjusted_point ) < dist_thr )
    {
        dlog.addText( Logger::TEAM,
                      __FILE__": reverted to the first target point" );
        adjusted_point = target_point;
    }

    {
        const double collision_dist
            = wm.self().playerType().playerSize()
            + SP.goalPostRadius()
            + 0.2;

        Vector2D goal_post_l( -SP.pitchHalfLength() + SP.goalPostRadius(),
                              -SP.goalHalfWidth() - SP.goalPostRadius() );
        Vector2D goal_post_r( -SP.pitchHalfLength() + SP.goalPostRadius(),
                              +SP.goalHalfWidth() + SP.goalPostRadius() );
        double dist_post_l = wm.self().pos().dist( goal_post_l );
        double dist_post_r = wm.self().pos().dist( goal_post_r );

        const Vector2D & nearest_post = ( dist_post_l < dist_post_r
                                          ? goal_post_l
                                          : goal_post_r );
        double dist_post = std::min( dist_post_l, dist_post_r );

        if ( dist_post < collision_dist + wm.self().playerType().realSpeedMax() + 0.5 )
        {
            Circle2D post_circle( nearest_post, collision_dist );
            Segment2D move_line( wm.self().pos(), adjusted_point );

            if ( post_circle.intersection( move_line, NULL, NULL ) > 0 )
            {
                AngleDeg post_angle = ( nearest_post - wm.self().pos() ).th();
                if ( nearest_post.y < wm.self().pos().y )
                {
                    adjusted_point = nearest_post;
                    adjusted_point += Vector2D::from_polar( collision_dist + 0.1, post_angle - 90.0 );
                    // Vector2D rel = adjusted_point - wm.self().pos();
                    // rel.rotate( -45.0 );
                    // adjusted_point = wm.self().pos() + rel;
                }
                else
                {
                    adjusted_point = nearest_post;
                    adjusted_point += Vector2D::from_polar( collision_dist + 0.1, post_angle + 90.0 );
                    // Vector2D rel = adjusted_point - wm.self().pos();
                    // rel.rotate( +45.0 );
                    // adjusted_point = wm.self().pos() + rel;
                }

                dist_thr = 0.05;
                dlog.addText( Logger::TEAM,
                              __FILE__": adjust to avoid goal post. (%.2f %.2f)",
                              adjusted_point.x, adjusted_point.y );
            }
        }
    }

    agent->debugClient().addMessage( "IndFKMove" );
    agent->debugClient().setTarget( adjusted_point );
    agent->debugClient().addCircle( adjusted_point, dist_thr );

    if ( ! Body_GoToPoint( adjusted_point,
                           dist_thr,
                           dash_power
                           ).execute( agent ) )
    {
        // already there
        Body_TurnToBall().execute( agent );
        dlog.addText( Logger::TEAM,
                      __FILE__":  their kick. turn to ball" );
    }

    agent->setNeckAction( new Neck_TurnToBall() );
}