// File: /workspace/github_cpp_makefile_star2_O2/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 %rdi, %r14
movq 0x8(%rdi), %rax
leaq -0x118(%rbp), %r15
movl $0x1, -0x20(%r15)
movq %rax, -0x18(%r15)
andq $0x0, -0x10(%r15)
andl $0x0, -0x8(%r15)
andl $0x0, 0x38(%r15)
andq $0x0, 0x40(%r15)
andl $0x0, 0x48(%r15)
andq $0x0, 0x50(%r15)
andl $0x0, 0x58(%r15)
andq $0x0, 0x60(%r15)
movq %rsi, %rbx
andl $0x0, 0x68(%r15)
andq $0x0, 0x70(%r15)
xorpd %xmm0, %xmm0
movupd %xmm0, (%r15)
movupd %xmm0, 0x10(%r15)
movupd %xmm0, 0x20(%r15)
movb $0x0, 0x30(%r15)
andq $0x0, 0x80(%r15)
movq 0x10(%rdi), %rsi
movq 0x20(%rdi), %rdx
movl 0x1c(%rsi), %ecx
cmpb $0x1, 0x175(%rdx)
jne 0x15eba
cmpl $0x35, %ecx
ja 0x1624c
movl %ecx, %ecx
movabsq $0x3000000487c000, %rdx # imm = 0x3000000487C000
btq %rcx, %rdx
jb 0x1601c
movabsq $0xc000000000000, %rdx  # imm = 0xC000000000000
btq %rcx, %rdx
jae 0x160f0
movl $0x11, -0xa0(%rbp)
leaq -0x90(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x13e24
movq %r12, %rdi
movq %rbx, %rsi
callq 0x13e6e
leaq -0x90(%rbp), %rdi
callq 0x13e44
cmpq %rbx, (%rbx)
je 0x15e92
movq 0x20(%r14), %rax
cmpb $0x1, 0x175(%rax)
jne 0x15f74
testb $0x1, 0x138(%rax)
je 0x15f74
movq 0x8(%r14), %rsi
movq %r12, %rdi
callq 0x1315e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x13218
leaq -0x90(%rbp), %rdi
callq 0x1317e
jmp 0x15f74
cmpl $0x35, %ecx
ja 0x1624c
movl %ecx, %ecx
movabsq $0x30000004860000, %rdx # imm = 0x30000004860000
btq %rcx, %rdx
jb 0x1601c
movabsq $0xc000000018000, %rdx  # imm = 0xC000000018000
btq %rcx, %rdx
jae 0x1603c
movl $0x11, -0xa0(%rbp)
movq 0x38(%r14), %rdi
callq 0x40cec
testb %al, %al
je 0x15f74
movq 0x8(%r14), %rsi
leaq -0x90(%rbp), %r12
movq %r12, %rdi
callq 0x11c94
movq %r12, %rdi
movq %rbx, %rsi
callq 0x11cde
leaq -0x90(%rbp), %rdi
callq 0x11cb4
movq 0x8(%r14), %rsi
movq %r12, %rdi
callq 0x173ea
movq %r12, %rdi
movq %rbx, %rsi
callq 0x17434
leaq -0x90(%rbp), %rdi
callq 0x1740a
movq 0x8(%r14), %rsi
movq %r12, %rdi
callq 0x13e24
movq %r12, %rdi
movq %rbx, %rsi
callq 0x13e6e
leaq -0x90(%rbp), %rdi
callq 0x13e44
cmpq %rbx, (%rbx)
jne 0x1624c
movq 0x18(%r14), %rax
movups 0x8(%rax), %xmm0
movups %xmm0, -0x110(%rbp)
movq 0x20(%r14), %rcx
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
subsd 0x8(%rcx), %xmm0
subsd 0x10(%rcx), %xmm1
leaq -0x90(%rbp), %r12
movsd %xmm0, (%r12)
movsd %xmm1, 0x8(%r12)
movq %r12, %rdi
callq 0xcd30
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x41cec(%rip), %rcx     # 0x57cc0
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, -0x118(%rbp)
callq 0x26f9c
movq 0x8(%r14), %rsi
movl $0x1, (%r12)
leaq -0x90(%rbp), %rcx
movq %rax, %rdi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x27828
minsd 0x41039(%rip), %xmm0    # 0x57048
movsd %xmm0, -0xf0(%rbp)
jmp 0x1622c
movl $0x10, -0xa0(%rbp)
movabsq $0x404e000000000000, %rax # imm = 0x404E000000000000
movq %rax, -0x118(%rbp)
jmp 0x1623d
movabsq $0x2000000004000, %rdx  # imm = 0x2000000004000
btq %rcx, %rdx
jae 0x1624c
movl $0xf, -0xa0(%rbp)
movl 0x8(%rax), %eax
movq 0x38(%r14), %rcx
cmpl 0x148(%rcx), %eax
jne 0x16150
leaq 0x10(%rsi), %rdi
addq $0x24, %rsi
callq 0x4770c
movq 0x38(%r14), %rcx
cmpl $0x4, %eax
jg 0x16093
cmpb $0x1, 0x140(%rcx)
jne 0x16093
movb $0x0, 0x140(%rcx)
movq 0x20(%r14), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
addsd 0x41c07(%rip), %xmm0    # 0x57cb0
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd 0x40f87(%rip), %xmm1    # 0x57048
ucomisd %xmm0, %xmm1
movb 0x140(%rcx), %al
jbe 0x160d5
testb $0x1, %al
je 0x161a0
testb $0x1, %al
jne 0x161a7
movabsq $0x401a666666666666, %rax # imm = 0x401A666666666666
movq %rax, -0x110(%rbp)
jmp 0x16143
cmpq $0x31, %rcx
jne 0x1624c
movl $0xf, -0xa0(%rbp)
callq 0x3db2c
leaq 0x43db8(%rip), %rax     # 0x59ec8
movsd (%rax), %xmm0
mulsd 0x40f44(%rip), %xmm0    # 0x57060
movsd %xmm0, -0x28(%rbp)
callq 0x3db2c
movsd -0x28(%rbp), %xmm0
addsd 0x3278(%rax), %xmm0
addsd 0x40f35(%rip), %xmm0    # 0x57070
movsd %xmm0, -0x110(%rbp)
andq $0x0, -0x108(%rbp)
jmp 0x1622c
addl $-0x2, %eax
cvtsi2sd %eax, %xmm0
mulsd 0x41b41(%rip), %xmm0    # 0x57ca0
addsd 0x41b41(%rip), %xmm0    # 0x57ca8
movsd %xmm0, -0x118(%rbp)
movabsq $0x4020851eb851eb85, %rax # imm = 0x4020851EB851EB85
leaq -0x90(%rbp), %rdi
movq %rax, (%rdi)
movq %r15, %rsi
callq 0xd15b
movsd %xmm0, -0x110(%rbp)
movsd %xmm1, -0x108(%rbp)
jmp 0x1622c
movb $0x1, 0x140(%rcx)
callq 0x3db2c
leaq 0x43d15(%rip), %rax     # 0x59ec8
movsd (%rax), %xmm0
mulsd 0x41689(%rip), %xmm0    # 0x57848
movsd %xmm0, -0x28(%rbp)
callq 0x3db2c
movsd -0x28(%rbp), %xmm0
subsd 0x3268(%rax), %xmm0
leaq -0x90(%rbp), %rax
movsd %xmm0, (%rax)
movapd %xmm0, %xmm2
andq $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 0x40e34(%rip), %xmm1    # 0x57048
ucomisd %xmm0, %xmm1
leaq 0x8(%rcx), %rcx
cmovaq %rax, %rcx
movupd (%rcx), %xmm0
movupd %xmm0, -0x110(%rbp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x128(%rbp)
leaq -0x138(%rbp), %rsi
movq %rbx, %rdi
callq 0x10530
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x1317e
jmp 0x162a0
jmp 0x16280
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x1740a
jmp 0x162a0
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x13e44
jmp 0x162a0
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x11cb4
movq %rbx, %rdi
callq 0x98b0