// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rdi), %rsi
movl $0x1, -0xd0(%rbp)
movq %rsi, -0xc8(%rbp)
xorl %eax, %eax
movq %rax, -0xc0(%rbp)
movl %eax, -0xb8(%rbp)
movl %eax, -0x78(%rbp)
movq %rax, -0x70(%rbp)
movl %eax, -0x68(%rbp)
movq %rax, -0x60(%rbp)
movl %eax, -0x58(%rbp)
movq %rax, -0x50(%rbp)
movl %eax, -0x48(%rbp)
movq %rax, -0x40(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, -0xb0(%rbp)
movupd %xmm0, -0xa0(%rbp)
movupd %xmm0, -0x90(%rbp)
movb $0x0, -0x80(%rbp)
movq %rax, -0x30(%rbp)
movq 0x10(%rdi), %rax
movq 0x20(%rdi), %rdx
movl 0x1c(%rax), %ecx
cmpb $0x1, 0x175(%rdx)
jne 0x1995f
cmpl $0x35, %ecx
ja 0x19ad5
movl %ecx, %eax
movabsq $0x3000000487c000, %rcx # imm = 0x3000000487C000
btq %rax, %rcx
jb 0x19a88
movabsq $0xc000000000000, %rcx  # imm = 0xC000000000000
btq %rax, %rcx
jae 0x19b95
movl $0x11, -0x38(%rbp)
leaq -0x138(%rbp), %r15
movq %r15, %rdi
callq 0x16ee0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x16f40
leaq -0x138(%rbp), %rdi
callq 0x16f14
cmpq %rbx, (%rbx)
je 0x19937
movq 0x20(%r14), %rax
cmpb $0x1, 0x175(%rax)
jne 0x19a16
testb $0x1, 0x138(%rax)
je 0x19a16
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x15c86
movq %r15, %rdi
movq %rbx, %rsi
callq 0x15d72
leaq -0x138(%rbp), %rdi
callq 0x15cba
jmp 0x19a16
cmpl $0x35, %ecx
ja 0x19ad5
movl %ecx, %ecx
movabsq $0x30000004860000, %rdx # imm = 0x30000004860000
btq %rcx, %rdx
jb 0x19a88
movabsq $0xc000000018000, %rdx  # imm = 0xC000000018000
btq %rcx, %rdx
jae 0x19ae5
movl $0x11, -0x38(%rbp)
movq 0x38(%r14), %rdi
callq 0x4c90c
testb %al, %al
je 0x19a16
movq 0x8(%r14), %rsi
leaq -0x138(%rbp), %r15
movq %r15, %rdi
callq 0x145ec
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1464c
leaq -0x138(%rbp), %rdi
callq 0x14620
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x1b28e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1b2ee
leaq -0x138(%rbp), %rdi
callq 0x1b2c2
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x16ee0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x16f40
leaq -0x138(%rbp), %rdi
callq 0x16f14
cmpq %rbx, (%rbx)
jne 0x19ad5
leaq -0xb0(%rbp), %r15
movq 0x18(%r14), %rax
movups 0x8(%rax), %xmm0
movups %xmm0, 0x8(%r15)
movq 0x20(%r14), %rcx
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm0
subsd 0x8(%rcx), %xmm1
subsd 0x10(%rcx), %xmm0
movapd 0x4f5bd(%rip), %xmm2    # 0x69010
movapd %xmm1, %xmm4
andpd %xmm2, %xmm4
movsd 0x4f5dd(%rip), %xmm3    # 0x69040
ucomisd %xmm4, %xmm3
jbe 0x19bf5
andpd %xmm0, %xmm2
ucomisd %xmm2, %xmm3
jbe 0x19bf5
movsd 0x50275(%rip), %xmm0    # 0x69cf8
jmp 0x19c23
leaq -0xd0(%rbp), %r14
movl $0x10, 0x98(%r14)
movabsq $0x404e000000000000, %rax # imm = 0x404E000000000000
movq %rax, 0x20(%r14)
movl $0xb8, %edi
callq 0x94c0
movq %rax, %r15
leaq 0x10(%rax), %rdi
movl $0xa8, %edx
movq %r14, %rsi
callq 0x93e0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x90b0
incq 0x10(%rbx)
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movabsq $0x2000000004000, %rdx  # imm = 0x2000000004000
btq %rcx, %rdx
jae 0x19ad5
movl $0xf, -0x38(%rbp)
movl 0x8(%rsi), %ecx
movq 0x38(%r14), %rdx
cmpl 0x148(%rdx), %ecx
jne 0x19c99
leaq 0x10(%rax), %rdi
addq $0x24, %rax
movq %rax, %rsi
callq 0x546de
movq 0x38(%r14), %rcx
cmpl $0x4, %eax
jg 0x19b38
cmpb $0x1, 0x140(%rcx)
jne 0x19b38
movb $0x0, 0x140(%rcx)
movq 0x20(%r14), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
addsd 0x501a2(%rip), %xmm0    # 0x69cf0
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd 0x4f4f2(%rip), %xmm1    # 0x69058
ucomisd %xmm0, %xmm1
movb 0x140(%rcx), %al
jbe 0x19b7a
testb $0x1, %al
je 0x19d0f
testb $0x1, %al
jne 0x19d16
movabsq $0x401a666666666666, %rax # imm = 0x401A666666666666
movq %rax, -0xa8(%rbp)
jmp 0x19be5
cmpq $0x31, %rax
jne 0x19ad5
movl $0xf, -0x38(%rbp)
callq 0x49360
leaq 0x52336(%rip), %rax     # 0x6bee8
movsd (%rax), %xmm0
mulsd 0x4f4ca(%rip), %xmm0    # 0x69088
movsd %xmm0, -0x28(%rbp)
callq 0x49360
movsd -0x28(%rbp), %xmm0
addsd 0x3278(%rax), %xmm0
addsd 0x4f4bb(%rip), %xmm0    # 0x69098
movsd %xmm0, -0xa8(%rbp)
movq $0x0, -0xa0(%rbp)
jmp 0x19d9e
callq 0x90d0
mulsd 0x4f446(%rip), %xmm0    # 0x69048
divsd 0x4f446(%rip), %xmm0    # 0x69050
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x500e2(%rip), %rcx     # 0x69d00
movsd (%rcx,%rax,8), %xmm0
leaq -0xd0(%rbp), %r12
movsd %xmm0, 0x20(%r12)
callq 0x2d3f2
movq 0x8(%r14), %rsi
leaq -0x138(%rbp), %rcx
movl $0x1, (%rcx)
movq %rax, %rdi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x2e004
minsd 0x4f3fb(%rip), %xmm0    # 0x69058
movsd %xmm0, 0x48(%r12)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x10(%r12)
movl $0xb8, %edi
callq 0x94c0
movq %rax, %r14
leaq 0x10(%rax), %rdi
movl $0xa8, %edx
movq %r12, %rsi
callq 0x93e0
movq %r14, %rdi
jmp 0x19ac9
addl $-0x2, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd 0x5002d(%rip), %xmm0    # 0x69cd8
addsd 0x5002d(%rip), %xmm0    # 0x69ce0
movsd %xmm0, -0xb0(%rbp)
mulsd 0x4f38d(%rip), %xmm0    # 0x69050
divsd 0x4f37d(%rip), %xmm0    # 0x69048
leaq -0x138(%rbp), %r14
leaq -0x140(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x92d0
movsd 0x4fffc(%rip), %xmm0    # 0x69ce8
movsd (%r15), %xmm1
mulsd %xmm0, %xmm1
mulsd (%r14), %xmm0
movsd %xmm1, -0xa8(%rbp)
movsd %xmm0, -0xa0(%rbp)
jmp 0x19d9e
movb $0x1, 0x140(%rcx)
callq 0x49360
leaq 0x521c6(%rip), %rax     # 0x6bee8
movsd (%rax), %xmm0
mulsd 0x4fb4a(%rip), %xmm0    # 0x69878
movsd %xmm0, -0x28(%rbp)
callq 0x49360
movsd -0x28(%rbp), %xmm0
subsd 0x3268(%rax), %xmm0
leaq -0x138(%rbp), %rax
movsd %xmm0, (%rax)
movapd %xmm0, %xmm2
movq $0x0, 0x8(%rax)
movq 0x18(%r14), %rcx
movsd 0x8(%rcx), %xmm0
movsd 0x10(%rcx), %xmm1
subsd %xmm2, %xmm0
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd 0x4f2d2(%rip), %xmm1    # 0x69058
ucomisd %xmm0, %xmm1
leaq 0x8(%rcx), %rcx
cmovaq %rax, %rcx
movupd (%rcx), %xmm0
movupd %xmm0, -0xa8(%rbp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
leaq -0xd0(%rbp), %r14
movq %rax, 0x10(%r14)
jmp 0x19aa8
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
callq 0x15cba
jmp 0x19dfc
jmp 0x19ddc
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
callq 0x1b2c2
jmp 0x19dfc
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
callq 0x16f14
jmp 0x19dfc
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
callq 0x14620
movq %rbx, %rdi
callq 0x98b0