// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/VisualSystem.cpp
// Function: VisualSystem::GetBestVisualAction()
void VisualSystem::GetBestVisualAction() {
  if (mIsCritical) {
    if (NewSightComeCycle(VW_Wide) == 1) {
      ChangeViewWidth(VW_Wide);
    } else if (NewSightComeCycle(VW_Normal) == 1) {
      ChangeViewWidth(VW_Normal);
    } else {
      ChangeViewWidth(VW_Narrow);
    }

    mBestVisualAction = GetBestVisualActionWithViewWidth(mViewWidth, true);
  } else {
    if (mViewWidth != VW_Narrow && !mIsSearching) {
      mBestVisualAction = GetBestVisualActionWithViewWidth(mViewWidth, true);
    } else {
      mCanForceChangeViewWidth = true;

      Array<VisualAction, 3> best_visual_action;

      //球在3.0米以内，尽量保证每周期都能感知到球，除非对球的下周期状态预测很有把握
      const bool force =
          mpWorldState->GetPlayMode() != PM_Our_Penalty_Taken &&
          mpWorldState->GetBall().GetPosDelay() == 0 &&
          mpWorldState->GetHistory(1)->GetBall().GetPosDelay() == 0 &&
          mpAgent->GetInfoState()
                  .GetPositionInfo()
                  .GetClosestOpponentDistToBall() > 3.0;

      if (force && PlayerParam::instance().SaveTextLog()) {
        Logger::instance().GetTextLogger("sure_ball")
            << mpWorldState->CurrentTime() << std::endl;
      }

      if (NewSightComeCycle(VW_Wide) == 1) {
        best_visual_action[2] =
            GetBestVisualActionWithViewWidth(VW_Wide, force);
      } else if (NewSightComeCycle(VW_Normal) == 1) {
        best_visual_action[1] =
            GetBestVisualActionWithViewWidth(VW_Normal, force);
        best_visual_action[2] =
            GetBestVisualActionWithViewWidth(VW_Wide, force);
      } else {
        best_visual_action[0] =
            GetBestVisualActionWithViewWidth(VW_Narrow, force);
        best_visual_action[1] =
            GetBestVisualActionWithViewWidth(VW_Normal, force);
        best_visual_action[2] =
            GetBestVisualActionWithViewWidth(VW_Wide, force);
      }

      const double buffer = FLOAT_EPS;
      if (best_visual_action[0].mScore >
          best_visual_action[1].mScore - buffer) {
        if (best_visual_action[0].mScore >
            best_visual_action[2].mScore - buffer) {
          // narrow
          ChangeViewWidth(VW_Narrow);
          mBestVisualAction = best_visual_action[0];
        } else {
          // wide
          ChangeViewWidth(VW_Wide);
          mBestVisualAction = best_visual_action[2];
        }
      } else {
        if (best_visual_action[1].mScore >
            best_visual_action[2].mScore - buffer) {
          // normal
          ChangeViewWidth(VW_Normal);
          mBestVisualAction = best_visual_action[1];
        } else {
          // wide
          ChangeViewWidth(VW_Wide);
          mBestVisualAction = best_visual_action[2];
        }
      }
    }
  }

  mBestVisualAction.mDir += mPreBodyDir;
  // Assert(mBestVisualAction.mScore > 0.0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x638(%rdi)
jne 0x56e5f
movq 0x20(%rbx), %rax
movl 0x18(%rax), %eax
cmpl $0x2, %eax
jl 0x56fbb
movl $0x3, 0x640(%rbx)
movl $0x3, %esi
jmp 0x570ac
movl 0x640(%rbx), %esi
cmpl $0x1, %esi
je 0x56e77
cmpb $0x0, 0x63a(%rbx)
je 0x570ac
movb $0x1, 0x639(%rbx)
movl $0x8, %eax
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
movq $0x0, -0x60(%rbp,%rax)
movq %rcx, -0x58(%rbp,%rax)
addq $0x10, %rax
cmpq $0x38, %rax
jne 0x56e8d
movq 0x10(%rbx), %rdi
cmpl $0x10, 0x1c(%rdi)
je 0x56f8a
cmpl $0x0, 0x48(%rdi)
jne 0x56f8a
movl $0x1, %esi
callq 0x5a460
cmpl $0x0, 0x48(%rax)
jne 0x56f8a
movq 0x8(%rbx), %rax
movq 0x20(%rax), %rdi
callq 0x2a4b4
movq %rax, %rdi
callq 0x599b6
ucomisd 0x12d32(%rip), %xmm0    # 0x69c20
jbe 0x56f8a
callq 0x43dce
movb $0x1, %r12b
cmpb $0x1, 0x5c45(%rax)
jne 0x56f8d
callq 0x34c60
leaq 0x16733(%rip), %rsi     # 0x6d648
movq %rax, %rdi
callq 0x34e74
movq %rax, %r14
movq 0x10(%rbx), %r15
callq 0x43dce
cmpb $0x1, 0x5c45(%rax)
jne 0x56f45
addq $0x10, %r15
leaq 0x210(%r14), %rdi
movq %r15, %rsi
callq 0xe974
callq 0x43dce
cmpb $0x1, 0x5c45(%rax)
jne 0x56f8d
movq %r14, %r15
addq $0x210, %r15            # imm = 0x210
movq 0x210(%r14), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r15, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
jmp 0x56f8d
xorl %r12d, %r12d
movq 0x20(%rbx), %rax
movl 0x18(%rax), %eax
cmpl $0x2, %eax
jl 0x56fd8
movzbl %r12b, %edx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x594bc
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd -0x40(%rbp), %xmm4
jmp 0x57039
cmpl $0x1, %eax
jne 0x5709d
movl $0x2, 0x640(%rbx)
movl $0x2, %esi
jmp 0x570ac
movzbl %r12b, %r14d
cmpl $0x1, %eax
je 0x56ffb
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x594bc
movsd %xmm0, -0x58(%rbp)
movsd %xmm1, -0x50(%rbp)
movq %rbx, %rdi
movl $0x2, %esi
movl %r14d, %edx
callq 0x594bc
movsd %xmm1, -0x28(%rbp)
movsd %xmm0, -0x48(%rbp)
movsd %xmm1, -0x40(%rbp)
movq %rbx, %rdi
movl $0x3, %esi
movl %r14d, %edx
callq 0x594bc
movsd -0x28(%rbp), %xmm4
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd -0x50(%rbp), %xmm0
movsd 0x12032(%rip), %xmm2    # 0x69078
movapd %xmm4, %xmm3
addsd %xmm2, %xmm3
ucomisd %xmm3, %xmm0
addsd %xmm2, %xmm1
jbe 0x57069
ucomisd %xmm1, %xmm0
jbe 0x5707a
leaq -0x58(%rbp), %rax
movl $0x1, %ecx
jmp 0x57083
ucomisd %xmm1, %xmm4
jbe 0x5707a
leaq -0x48(%rbp), %rax
movl $0x2, %ecx
jmp 0x57083
movl $0x3, %ecx
leaq -0x38(%rbp), %rax
movl %ecx, 0x640(%rbx)
movups (%rax), %xmm0
movups %xmm0, 0x670(%rbx)
movsd 0x670(%rbx), %xmm0
jmp 0x570c1
movl $0x1, 0x640(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x594bc
movsd %xmm1, 0x678(%rbx)
addsd 0x648(%rbx), %xmm0
movsd %xmm0, 0x670(%rbx)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq