// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/BehaviorPenalty.cpp
// Function: BehaviorPenaltyPlanner::Plan(std::__cxx11::list<ActiveBehavior, std::allocator<ActiveBehavior>>&)
void BehaviorPenaltyPlanner::Plan(std::list<ActiveBehavior> &behaviorlist) {
  ActiveBehavior penaltyKO(mAgent, BT_Penalty);

  if (mSelfState.IsGoalie()) {
    switch (mWorldState.GetPlayMode()) {
    case PM_Penalty_On_Our_Field:
    case PM_Penalty_On_Opp_Field:
    case PM_Our_Penalty_Score:
    case PM_Our_Penalty_Miss:
    case PM_Opp_Penalty_Score:
    case PM_Opp_Penalty_Miss: // 对手或队友刚罚完点球，原地休息一会
    case PM_Our_Penalty_Setup:
    case PM_Our_Penalty_Ready:
    case PM_Our_Penalty_Taken: // 队友罚点球，守门员在旁边休息，为了节省体力，不自己dash回去（rcssserver-13.*下不可能是守门员自己罚）
      penaltyKO.mDetailType = BDT_Setplay_Scan;
      break;
    case PM_Opp_Penalty_Setup:
      penaltyKO.mDetailType = BDT_Setplay_Move;
      break;
    case PM_Opp_Penalty_Ready:
    case PM_Opp_Penalty_Taken:
      penaltyKO.mDetailType = BDT_Setplay_GetBall; // 正在罚点球
      break;
    default:
      return;
    }
  } else {
    switch (mWorldState.GetPlayMode()) {
    case PM_Penalty_On_Our_Field:
    case PM_Penalty_On_Opp_Field:
    case PM_Our_Penalty_Score:
    case PM_Our_Penalty_Miss:
    case PM_Opp_Penalty_Score:
    case PM_Opp_Penalty_Miss:
      penaltyKO.mDetailType = BDT_Setplay_Scan; // 原地休息
      break;
    case PM_Our_Penalty_Setup:
    case PM_Opp_Penalty_Setup:
      penaltyKO.mDetailType = BDT_Setplay_Move; // 走向目标位置
      break;
    case PM_Our_Penalty_Ready:
    case PM_Our_Penalty_Taken:
    case PM_Opp_Penalty_Ready:
    case PM_Opp_Penalty_Taken:
      penaltyKO.mDetailType = BDT_Setplay_GetBall; // 正在罚点球
      break;
    default:
      return;
    }
  }

  if (penaltyKO.mDetailType == BDT_Setplay_Scan) {
    penaltyKO.mAngle = 60.0;
    behaviorlist.push_back(penaltyKO);
  } else if (penaltyKO.mDetailType == BDT_Setplay_Move) {
    if (mSelfState.IsGoalie()) {
      penaltyKO.mTarget =
          Vector(-ServerParam::instance().PITCH_LENGTH / 2.0 +
                     ServerParam::instance().penMaxGoalieDistX() - 1.0,
                 0.0);
    } else if (mAgent.GetSelfUnum() == mStrategy.GetPenaltyTaker()) {
      if (mWorldState.CurrentTime() - mWorldState.GetPlayModeTime() < 5 &&
          mStrategy.IsPenaltyFirstStep() != false) {
        mStrategy.SetPenaltyFirstStep(false);
      }

      if (mSelfState.GetPos().Dist(Vector(6.6, 0.0)) < 1.0 &&
          mStrategy.IsPenaltyFirstStep() != true) {
        mStrategy.SetPenaltyFirstStep(true);
      }

      if (mStrategy.IsPenaltyFirstStep() == false) {
        penaltyKO.mTarget = Vector(6.6, 0.0);
      } else {
        const Vector setup_ball_pos =
            Vector(ServerParam::instance().PITCH_LENGTH / 2.0 -
                       ServerParam::instance().penDistX(),
                   0.0);
        penaltyKO.mTarget = (mBallState.GetPos().Dist(setup_ball_pos) < 1.0)
                                ? setup_ball_pos
                                : mBallState.GetPos();
      }
    } else {
      penaltyKO.mAngle = (mAgent.GetSelfUnum() - 2) * 36.0 + 18.0; // 2 ~ 11
      penaltyKO.mTarget = Polar2Vector(8.26, penaltyKO.mAngle);
    }

    penaltyKO.mEvaluation = 1.0;
    behaviorlist.push_back(penaltyKO);
  } else if (penaltyKO.mDetailType == BDT_Setplay_GetBall) {
    if (mSelfState.IsGoalie()) {
      BehaviorInterceptPlanner(mAgent).Plan(behaviorlist);
      if (behaviorlist.empty() || mSelfState.IsBallCatchable())
        BehaviorGoaliePlanner(mAgent).Plan(behaviorlist);
    } else if (mStrategy.IsMyPenaltyTaken() == true) {
      // 先算dribble，shoot中根据dribble的情况来决策
      BehaviorDribblePlanner(mAgent).Plan(behaviorlist);
      BehaviorShootPlanner(mAgent).Plan(behaviorlist);
      BehaviorInterceptPlanner(mAgent).Plan(behaviorlist);
    }

    if (behaviorlist.empty()) {
      penaltyKO.mTarget = mBallState.GetPos();
      penaltyKO.mAngle =
          ((mBallState.GetPos() - mSelfState.GetPos()).Dir() > 0.0) ? 36.0
                                                                    : -36.0;
      penaltyKO.mKickSpeed =
          Min(1.0, Kicker::instance().GetMaxSpeed(mAgent, penaltyKO.mAngle, 1));
      penaltyKO.mEvaluation = 1.0;
      behaviorlist.push_back(penaltyKO);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3f0, %rsp            # imm = 0x3F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x378(%rbp)
movq 0x8(%rax), %rsi
leaq -0xb8(%rbp), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x1b4d0
movq -0x378(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1d780
testb $0x1, %al
jne 0x247ee
jmp 0x2487e
movq -0x378(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
movl %eax, %ecx
movl %ecx, %eax
addl $-0xe, %eax
movl %ecx, -0x37c(%rbp)
subl $0x5, %eax
jb 0x24859
jmp 0x24812
movl -0x37c(%rbp), %eax
subl $0x17, %eax
je 0x24859
jmp 0x2481f
movl -0x37c(%rbp), %eax
subl $0x1a, %eax
je 0x24859
jmp 0x2482c
movl -0x37c(%rbp), %eax
subl $0x31, %eax
je 0x24862
jmp 0x24839
movl -0x37c(%rbp), %eax
addl $-0x32, %eax
subl $0x2, %eax
jb 0x2486b
jmp 0x24849
movl -0x37c(%rbp), %eax
addl $-0x34, %eax
subl $0x1, %eax
ja 0x24874
jmp 0x24859
movl $0x10, -0x20(%rbp)
jmp 0x24879
movl $0xf, -0x20(%rbp)
jmp 0x24879
movl $0x11, -0x20(%rbp)
jmp 0x24879
jmp 0x2513a
jmp 0x24926
movq -0x378(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
movl %eax, %ecx
movl %ecx, -0x380(%rbp)
subl $0xe, %eax
je 0x2490d
jmp 0x2489d
movl -0x380(%rbp), %eax
addl $-0xf, %eax
subl $0x2, %eax
jb 0x24916
jmp 0x248ad
movl -0x380(%rbp), %eax
addl $-0x11, %eax
subl $0x2, %eax
jb 0x24904
jmp 0x248bd
movl -0x380(%rbp), %eax
subl $0x17, %eax
je 0x24904
jmp 0x248ca
movl -0x380(%rbp), %eax
subl $0x1a, %eax
je 0x24904
jmp 0x248d7
movl -0x380(%rbp), %eax
subl $0x31, %eax
je 0x2490d
jmp 0x248e4
movl -0x380(%rbp), %eax
addl $-0x32, %eax
subl $0x2, %eax
jb 0x24916
jmp 0x248f4
movl -0x380(%rbp), %eax
addl $-0x34, %eax
subl $0x1, %eax
ja 0x2491f
jmp 0x24904
movl $0x10, -0x20(%rbp)
jmp 0x24924
movl $0xf, -0x20(%rbp)
jmp 0x24924
movl $0x11, -0x20(%rbp)
jmp 0x24924
jmp 0x2513a
jmp 0x24926
cmpl $0x10, -0x20(%rbp)
jne 0x24951
movsd 0x9d35c(%rip), %xmm0    # 0xc1c90
movsd %xmm0, -0x98(%rbp)
movq -0x10(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x189a0
jmp 0x2513a
cmpl $0xf, -0x20(%rbp)
jne 0x24d8d
movq -0x378(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1d780
testb $0x1, %al
jne 0x24974
jmp 0x24a22
callq 0x855e0
leaq 0x9f6b8(%rip), %rax     # 0xc4038
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x9cb0d(%rip), %xmm1    # 0xc14b0
divsd %xmm1, %xmm0
movsd %xmm0, -0x388(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x25410
movsd -0x388(%rbp), %xmm0
addsd (%rax), %xmm0
movsd 0x9c640(%rip), %xmm1    # 0xc1010
subsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xd8(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x11a10
movq -0xc8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x24d68
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10e40
movl %eax, %ecx
movq -0x378(%rbp), %rax
movl %ecx, -0x38c(%rbp)
movq 0x38(%rax), %rdi
callq 0x253b0
movl %eax, %ecx
movl -0x38c(%rbp), %eax
cmpl %ecx, %eax
jne 0x24cdc
movq -0x378(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12100
movq %rax, %rcx
movq -0x378(%rbp), %rax
movq %rcx, -0x398(%rbp)
movq 0x10(%rax), %rdi
callq 0x253d0
movq -0x398(%rbp), %rdi
movq %rax, %rsi
callq 0x9ed10
cmpl $0x5, %eax
jge 0x24ac4
movq -0x378(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x25430
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x24ac4
movq -0x378(%rbp), %rax
movq 0x38(%rax), %rdi
xorl %esi, %esi
callq 0x25450
movq -0x378(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, -0x3a8(%rbp)
movsd 0x9d1a1(%rip), %xmm0    # 0xc1c88
movsd %xmm0, -0xf0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xf8(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0xf8(%rbp), %rdx
callq 0x11a10
movq -0x3a8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x1d6d0
movaps %xmm0, %xmm1
xorl %eax, %eax
movsd 0x9c4dc(%rip), %xmm0    # 0xc1010
ucomisd %xmm1, %xmm0
movb %al, -0x399(%rbp)
jbe 0x24b61
movq -0x378(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x25430
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
setne %al
movb %al, -0x399(%rbp)
movb -0x399(%rbp), %al
testb $0x1, %al
jne 0x24b6d
jmp 0x24b82
movq -0x378(%rbp), %rax
movq 0x38(%rax), %rdi
movl $0x1, %esi
callq 0x25450
movq -0x378(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x25430
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x24bf2
movsd 0x9d0e4(%rip), %xmm0    # 0xc1c88
movsd %xmm0, -0x110(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x118(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x11a10
movq -0x108(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x24cd7
callq 0x855e0
leaq 0x9f43a(%rip), %rax     # 0xc4038
movsd (%rax), %xmm0
movsd 0x9c8a6(%rip), %xmm1    # 0xc14b0
divsd %xmm1, %xmm0
movsd %xmm0, -0x3b0(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x25480
movsd -0x3b0(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x130(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x138(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x138(%rbp), %rdx
callq 0x11a10
movq -0x378(%rbp), %rax
movq 0x18(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
leaq -0x128(%rbp), %rsi
callq 0x1d6d0
movaps %xmm0, %xmm1
movsd 0x9c386(%rip), %xmm0    # 0xc1010
ucomisd %xmm1, %xmm0
jbe 0x24ca0
leaq -0x128(%rbp), %rax
movq %rax, -0x3b8(%rbp)
jmp 0x24cbb
movq -0x378(%rbp), %rax
movq 0x18(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, -0x3b8(%rbp)
movq -0x3b8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x90(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x24d66
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10e40
subl $0x2, %eax
cvtsi2sd %eax, %xmm0
movsd 0x9cf6d(%rip), %xmm1    # 0xc1c68
mulsd %xmm1, %xmm0
movsd 0x9cf79(%rip), %xmm1    # 0xc1c80
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd 0x9cf5d(%rip), %xmm0    # 0xc1c78
movsd %xmm0, -0x150(%rbp)
leaq -0xb8(%rbp), %rsi
addq $0x20, %rsi
leaq -0x150(%rbp), %rdi
callq 0x112c0
movsd %xmm0, -0x148(%rbp)
movsd %xmm1, -0x140(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x140(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x24d68
movsd 0x9c2a0(%rip), %xmm0    # 0xc1010
movsd %xmm0, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x189a0
jmp 0x25138
cmpl $0x11, -0x20(%rbp)
jne 0x25136
movq -0x378(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1d780
testb $0x1, %al
jne 0x24db0
jmp 0x24e9b
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x20cf0
movq -0x3c0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x20d80
jmp 0x24de0
leaq -0x1b0(%rbp), %rdi
callq 0x20d30
movq -0x10(%rbp), %rdi
callq 0x18580
testb $0x1, %al
jne 0x24e12
movq -0x378(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x184c0
testb $0x1, %al
jne 0x24e12
jmp 0x24e96
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x228(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x1f740
movq -0x3c8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1f8b0
jmp 0x24e42
leaq -0x228(%rbp), %rdi
callq 0x1f780
jmp 0x24e96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20d30
jmp 0x25143
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x1f780
jmp 0x25143
jmp 0x24fda
movq -0x378(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x8afb0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x24fd8
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x288(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x1ca40
movq -0x3d0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1cad0
jmp 0x24ee9
leaq -0x288(%rbp), %rdi
callq 0x1ca80
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x2e8(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
callq 0x27700
movq -0x3d8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x27790
jmp 0x24f25
leaq -0x2e8(%rbp), %rdi
callq 0x27740
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x348(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x20cf0
movq -0x3e0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x20d80
jmp 0x24f61
leaq -0x348(%rbp), %rdi
callq 0x20d30
jmp 0x24fd8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x1ca80
jmp 0x25143
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x27740
jmp 0x25143
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x20d30
jmp 0x25143
jmp 0x24fda
movq -0x10(%rbp), %rdi
callq 0x18580
testb $0x1, %al
jne 0x24fec
jmp 0x25134
movq -0x378(%rbp), %rax
movq 0x18(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rcx
movq -0x378(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, -0x90(%rbp)
movq 0x8(%rcx), %rcx
movq %rcx, -0x88(%rbp)
movq 0x18(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rcx
movq -0x378(%rbp), %rax
movq %rcx, -0x3e8(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq -0x3e8(%rbp), %rdi
movq %rax, %rsi
callq 0x110a0
movsd %xmm0, -0x358(%rbp)
movsd %xmm1, -0x350(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x10520
movaps %xmm0, %xmm1
movsd 0x9cbe8(%rip), %xmm3    # 0xc1c68
movsd 0x9cbe8(%rip), %xmm2    # 0xc1c70
xorps %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
movaps %xmm0, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd 0x9bf61(%rip), %xmm0    # 0xc1010
movsd %xmm0, -0x360(%rbp)
callq 0x4ff20
movq %rax, %rdi
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xb8(%rbp), %rdx
addq $0x20, %rdx
movl $0x1, -0x36c(%rbp)
leaq -0x36c(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x510a0
movsd %xmm0, -0x368(%rbp)
leaq -0x360(%rbp), %rdi
leaq -0x368(%rbp), %rsi
callq 0x12a60
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd 0x9bef4(%rip), %xmm0    # 0xc1010
movsd %xmm0, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x189a0
jmp 0x25136
jmp 0x25138
jmp 0x2513a
addq $0x3f0, %rsp            # imm = 0x3F0
popq %rbp
retq
movq -0x1b8(%rbp), %rdi
callq 0xaa60
nop