// File: 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
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x150(%rbp)
testb $0x1, 0x638(%rax)
je 0xa54ff
movq -0x150(%rbp), %rdi
movl $0x3, %esi
callq 0xa9800
cmpl $0x1, %eax
jne 0xa5480
movq -0x150(%rbp), %rdi
movl $0x3, %esi
callq 0x12ca0
jmp 0xa54bc
movq -0x150(%rbp), %rdi
movl $0x2, %esi
callq 0xa9800
cmpl $0x1, %eax
jne 0xa54a9
movq -0x150(%rbp), %rdi
movl $0x2, %esi
callq 0x12ca0
jmp 0xa54ba
movq -0x150(%rbp), %rdi
movl $0x1, %esi
callq 0x12ca0
jmp 0xa54bc
movq -0x150(%rbp), %rdi
movl 0x640(%rdi), %esi
movl $0x1, %edx
callq 0xa88e0
movq -0x150(%rbp), %rax
movsd %xmm0, -0x18(%rbp)
movsd %xmm1, -0x10(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, 0x670(%rax)
movq -0x10(%rbp), %rcx
movq %rcx, 0x678(%rax)
jmp 0xa5b52
movq -0x150(%rbp), %rax
cmpl $0x1, 0x640(%rax)
je 0xa5562
movq -0x150(%rbp), %rax
testb $0x1, 0x63a(%rax)
jne 0xa5562
movq -0x150(%rbp), %rdi
movl 0x640(%rdi), %esi
movl $0x1, %edx
callq 0xa88e0
movq -0x150(%rbp), %rax
movsd %xmm0, -0x28(%rbp)
movsd %xmm1, -0x20(%rbp)
movq -0x28(%rbp), %rcx
movq %rcx, 0x670(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x678(%rax)
jmp 0xa5b50
movq -0x150(%rbp), %rax
movb $0x1, 0x639(%rax)
leaq -0x58(%rbp), %rdi
callq 0xa9860
movq -0x150(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x10, %ecx
movb %al, -0x151(%rbp)
je 0xa5634
movq -0x150(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1ddd0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x151(%rbp)
jne 0xa5634
movq -0x150(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0xab550
movq %rax, %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1ddd0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x151(%rbp)
jne 0xa5634
movq -0x150(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2e810
movq %rax, %rdi
callq 0x49590
movq %rax, %rdi
callq 0xa92e0
movsd 0x1c591(%rip), %xmm1    # 0xc1bb8
ucomisd %xmm1, %xmm0
seta %al
movb %al, -0x151(%rbp)
movb -0x151(%rbp), %al
andb $0x1, %al
movb %al, -0x59(%rbp)
testb $0x1, -0x59(%rbp)
je 0xa56a3
callq 0x798a0
movq %rax, %rdi
callq 0x1aaf0
testb $0x1, (%rax)
je 0xa56a3
callq 0x5add0
movq %rax, %rdi
leaq 0x2005a(%rip), %rsi     # 0xc56c0
callq 0x5b110
movq %rax, %rcx
movq -0x150(%rbp), %rax
movq %rcx, -0x160(%rbp)
movq 0x10(%rax), %rdi
callq 0x12100
movq -0x160(%rbp), %rdi
movq %rax, %rsi
callq 0x1a640
movq %rax, %rdi
movq 0x58912(%rip), %rsi     # 0xfdfb0
callq 0x1a7c0
movq -0x150(%rbp), %rdi
movl $0x3, %esi
callq 0xa9800
cmpl $0x1, %eax
jne 0xa5705
movq -0x150(%rbp), %rdi
movb -0x59(%rbp), %al
movl $0x3, %esi
andb $0x1, %al
movzbl %al, %edx
callq 0xa88e0
movsd %xmm0, -0x70(%rbp)
movsd %xmm1, -0x68(%rbp)
movq $0x2, -0x78(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xa98c0
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0xa58dd
movq -0x150(%rbp), %rdi
movl $0x2, %esi
callq 0xa9800
cmpl $0x1, %eax
jne 0xa57d0
movq -0x150(%rbp), %rdi
movb -0x59(%rbp), %al
movl $0x2, %esi
andb $0x1, %al
movzbl %al, %edx
callq 0xa88e0
movsd %xmm0, -0x88(%rbp)
movsd %xmm1, -0x80(%rbp)
movq $0x1, -0x90(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xa98c0
movq -0x150(%rbp), %rdi
movq -0x88(%rbp), %rcx
movq %rcx, (%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x8(%rax)
movb -0x59(%rbp), %al
movl $0x3, %esi
andb $0x1, %al
movzbl %al, %edx
callq 0xa88e0
movsd %xmm0, -0xa0(%rbp)
movsd %xmm1, -0x98(%rbp)
movq $0x2, -0xa8(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0xa98c0
movq -0xa0(%rbp), %rcx
movq %rcx, (%rax)
movq -0x98(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0xa58db
movq -0x150(%rbp), %rdi
movb -0x59(%rbp), %al
movl $0x1, %esi
andb $0x1, %al
movzbl %al, %edx
callq 0xa88e0
movsd %xmm0, -0xb8(%rbp)
movsd %xmm1, -0xb0(%rbp)
movq $0x0, -0xc0(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xa98c0
movq -0x150(%rbp), %rdi
movq -0xb8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xb0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movb -0x59(%rbp), %al
movl $0x2, %esi
andb $0x1, %al
movzbl %al, %edx
callq 0xa88e0
movsd %xmm0, -0xd0(%rbp)
movsd %xmm1, -0xc8(%rbp)
movq $0x1, -0xd8(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xa98c0
movq -0x150(%rbp), %rdi
movq -0xd0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xc8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movb -0x59(%rbp), %al
movl $0x3, %esi
andb $0x1, %al
movzbl %al, %edx
callq 0xa88e0
movsd %xmm0, -0xe8(%rbp)
movsd %xmm1, -0xe0(%rbp)
movq $0x2, -0xf0(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa98c0
movq -0xe8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xe0(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0xa58dd
movsd 0x1b723(%rip), %xmm0    # 0xc1008
movsd %xmm0, -0xf8(%rbp)
movq $0x0, -0x100(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xa98c0
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x168(%rbp)
movq $0x1, -0x108(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xa98c0
movsd -0x168(%rbp), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x1b6c3(%rip), %xmm2    # 0xc1008
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa5a52
movq $0x0, -0x110(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xa98c0
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x170(%rbp)
movq $0x2, -0x118(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0xa98c0
movsd -0x170(%rbp), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x1b65d(%rip), %xmm2    # 0xc1008
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa5a02
movq -0x150(%rbp), %rdi
movl $0x1, %esi
callq 0x12ca0
movq $0x0, -0x120(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xa98c0
movq %rax, %rcx
movq -0x150(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0x670(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x678(%rax)
jmp 0xa5a4d
movq -0x150(%rbp), %rdi
movl $0x3, %esi
callq 0x12ca0
movq $0x2, -0x128(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0xa98c0
movq %rax, %rcx
movq -0x150(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0x670(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x678(%rax)
jmp 0xa5b4e
movq $0x1, -0x130(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xa98c0
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x178(%rbp)
movq $0x2, -0x138(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0xa98c0
movsd -0x178(%rbp), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x1b55e(%rip), %xmm2    # 0xc1008
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa5b01
movq -0x150(%rbp), %rdi
movl $0x2, %esi
callq 0x12ca0
movq $0x1, -0x140(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xa98c0
movq %rax, %rcx
movq -0x150(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0x670(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x678(%rax)
jmp 0xa5b4c
movq -0x150(%rbp), %rdi
movl $0x3, %esi
callq 0x12ca0
movq $0x2, -0x148(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0xa98c0
movq %rax, %rcx
movq -0x150(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0x670(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x678(%rax)
jmp 0xa5b4e
jmp 0xa5b50
jmp 0xa5b52
movq -0x150(%rbp), %rax
movsd 0x648(%rax), %xmm0
addsd 0x670(%rax), %xmm0
movsd %xmm0, 0x670(%rax)
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw (%rax,%rax)