// File: /workspace/github_cpp_makefile_star2_O2/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 $0x30, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x638(%rdi)
jne 0x49a06
movq 0x20(%rbx), %rax
movl 0x18(%rax), %eax
cmpl $0x2, %eax
jl 0x49b43
movl $0x3, 0x640(%rbx)
pushq $0x3
jmp 0x49b92
movl 0x640(%rbx), %esi
cmpl $0x1, %esi
je 0x49a1e
cmpb $0x0, 0x63a(%rbx)
je 0x49b93
movb $0x1, 0x639(%rbx)
leaq -0x50(%rbp), %r14
movq %r14, %rdi
callq 0x4bf2c
movq 0x10(%rbx), %rdi
cmpl $0x10, 0x1c(%rdi)
je 0x49ab4
cmpl $0x0, 0x48(%rdi)
jne 0x49ab4
pushq $0x1
popq %rsi
callq 0x4c81e
cmpl $0x0, 0x48(%rax)
jne 0x49ab4
movq 0x8(%rbx), %rax
movq 0x20(%rax), %rdi
callq 0x244e8
movq %rax, %rdi
callq 0x4be12
ucomisd 0xe184(%rip), %xmm0     # 0x57bf0
jbe 0x49ab4
callq 0x38d94
movb $0x1, %r15b
cmpb $0x1, 0x5c45(%rax)
jne 0x49ab7
callq 0x2ca2e
leaq 0x11b9d(%rip), %rsi     # 0x5b628
movq %rax, %rdi
callq 0x2cc3e
movq 0x10(%rbx), %rsi
addq $0x10, %rsi
movq %rax, %rdi
callq 0x10e94
movq 0x2d506(%rip), %rsi     # 0x76fb0
movq %rax, %rdi
callq 0x10f5c
jmp 0x49ab7
xorl %r15d, %r15d
movq 0x20(%rbx), %rax
cmpl $0x1, 0x18(%rax)
movzbl %r15b, %r12d
jg 0x49af7
je 0x49adf
pushq $0x1
popq %rsi
movq %rbx, %rdi
movl %r12d, %edx
callq 0x4b9b2
movsd %xmm0, -0x50(%rbp)
movsd %xmm1, -0x48(%rbp)
pushq $0x2
popq %rsi
movq %rbx, %rdi
movl %r12d, %edx
callq 0x4b9b2
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
pushq $0x3
popq %r15
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x4b9b2
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movsd 0xd52b(%rip), %xmm3     # 0x57050
movapd %xmm2, %xmm4
addsd %xmm3, %xmm4
ucomisd %xmm4, %xmm0
addsd %xmm3, %xmm1
jbe 0x49b56
ucomisd %xmm1, %xmm0
jbe 0x49b66
pushq $0x1
popq %r15
jmp 0x49b6a
cmpl $0x1, %eax
jne 0x49b86
movl $0x2, 0x640(%rbx)
pushq $0x2
jmp 0x49b92
ucomisd %xmm1, %xmm2
jbe 0x49b66
pushq $0x2
popq %r15
leaq -0x40(%rbp), %r14
jmp 0x49b6a
leaq -0x30(%rbp), %r14
movl %r15d, 0x640(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x670(%rbx)
movsd 0x670(%rbx), %xmm0
jmp 0x49ba6
movl $0x1, 0x640(%rbx)
pushq $0x1
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x4b9b2
movsd %xmm1, 0x678(%rbx)
addsd 0x648(%rbx), %xmm0
movsd %xmm0, 0x670(%rbx)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop