// File: /workspace/github_cpp_makefile_star2_O1/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 0x586c0
movq 0x20(%rbx), %rax
movl 0x18(%rax), %eax
cmpl $0x2, %eax
jl 0x58856
movl $0x3, 0x640(%rbx)
jmp 0x5889d
movl 0x640(%rbx), %esi
cmpl $0x1, %esi
je 0x586d8
cmpb $0x0, 0x63a(%rbx)
je 0x588a3
movb $0x1, 0x639(%rbx)
movl $0x8, %eax
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
movq $0x0, -0x58(%rbp,%rax)
movq %rcx, -0x50(%rbp,%rax)
addq $0x10, %rax
cmpq $0x38, %rax
jne 0x586ee
movq 0x10(%rbx), %rdi
cmpl $0x10, 0x1c(%rdi)
je 0x5872a
cmpl $0x0, 0x48(%rdi)
jne 0x5872a
movl $0x1, %esi
callq 0x5bd3e
cmpl $0x0, 0x48(%rax)
je 0x588e5
xorl %r12d, %r12d
testb %r12b, %r12b
je 0x587c3
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x587c3
callq 0x35b4a
leaq 0x16f38(%rip), %rsi     # 0x6f688
movq %rax, %rdi
callq 0x35d5e
movq %rax, %r14
movq 0x10(%rbx), %r15
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x58780
addq $0x10, %r15
leaq 0x210(%r14), %rdi
movq %r15, %rsi
callq 0xea74
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x587c3
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
movq 0x20(%rbx), %rax
cmpl $0x1, 0x18(%rax)
movzbl %r12b, %r14d
jg 0x58807
je 0x587ed
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x5ad26
movsd %xmm0, -0x50(%rbp)
movsd %xmm1, -0x48(%rbp)
movq %rbx, %rdi
movl $0x2, %esi
movl %r14d, %edx
callq 0x5ad26
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
movq %rbx, %rdi
movl $0x3, %esi
movl %r14d, %edx
callq 0x5ad26
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movsd 0x12845(%rip), %xmm3    # 0x6b078
movapd %xmm2, %xmm4
addsd %xmm3, %xmm4
ucomisd %xmm4, %xmm0
addsd %xmm3, %xmm1
jbe 0x58867
ucomisd %xmm1, %xmm0
jbe 0x58878
leaq -0x50(%rbp), %rax
movl $0x1, %ecx
jmp 0x58881
cmpl $0x1, %eax
jne 0x58893
movl $0x2, 0x640(%rbx)
jmp 0x5889d
ucomisd %xmm1, %xmm2
jbe 0x58878
leaq -0x40(%rbp), %rax
movl $0x2, %ecx
jmp 0x58881
movl $0x3, %ecx
leaq -0x30(%rbp), %rax
movl %ecx, 0x640(%rbx)
movups (%rax), %xmm0
movups %xmm0, 0x670(%rbx)
jmp 0x588c0
movl $0x1, 0x640(%rbx)
movl 0x640(%rbx), %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x5ad26
movsd %xmm0, 0x670(%rbx)
movsd %xmm1, 0x678(%rbx)
movsd 0x648(%rbx), %xmm0
addsd 0x670(%rbx), %xmm0
movsd %xmm0, 0x670(%rbx)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbx), %rax
movq 0x20(%rax), %rdi
callq 0x2adf8
movq %rax, %rdi
callq 0x5b240
ucomisd 0x1331e(%rip), %xmm0    # 0x6bc20
seta %r12b
jmp 0x5872d
nop