// File: /workspace/github_cpp_makefile_star2_O1/wrighteagle2d[P]wrighteaglebase/Debug/../src/ServerParam.cpp
// Function: ServerParam::MaintainConsistency()
void ServerParam::MaintainConsistency() {
  M_kickable_area = M_player_size + M_kickable_margin + M_ball_size;
  M_control_radius_width = M_control_radius - M_player_size;

  M_max_catchable_area =
      Vector(M_catchable_area_l, 0.5 * M_catchable_area_w).Mod();
  M_one_minus_ball_decay = 1.0 - M_ball_decay;
  M_log_ball_decay = log(M_ball_decay);

  M_ball_decay_array[0] = 1.0;
  for (int i = 1; i < 100; ++i) {
    M_ball_decay_array[i] = M_ball_decay_array[i - 1] * M_ball_decay;
  }

  // set the field information
  M_left_line =
      Line(Vector(-PITCH_LENGTH / 2.0, 0.0), Vector(-PITCH_LENGTH / 2.0, 1.0));
  M_right_line =
      Line(Vector(PITCH_LENGTH / 2.0, 0.0), Vector(PITCH_LENGTH / 2.0, 1.0));
  M_top_line =
      Line(Vector(0.0, -PITCH_WIDTH / 2.0), Vector(1.0, -PITCH_WIDTH / 2.0));
  M_bottom_line =
      Line(Vector(0.0, PITCH_WIDTH / 2.0), Vector(1.0, PITCH_WIDTH / 2.0));

  M_pitch_rectanglar = Rectangular(-PITCH_LENGTH / 2.0, PITCH_LENGTH / 2.0,
                                   -PITCH_WIDTH / 2.0, PITCH_WIDTH / 2.0);
  M_active_rectanglar =
      Rectangular(-PITCH_LENGTH / 2.0 + 1.0, PITCH_LENGTH / 2.0 - 1.0,
                  -PITCH_WIDTH / 2.0 + 1.0, PITCH_WIDTH / 2.0 - 1.0);
  M_our_penalty_area = Rectangular(
      -PITCH_LENGTH / 2.0, -PITCH_LENGTH / 2.0 + PENALTY_AREA_LENGTH,
      -PENALTY_AREA_WIDTH / 2.0, PENALTY_AREA_WIDTH / 2.0);
  M_opp_penalty_area =
      Rectangular(PITCH_LENGTH / 2.0 - PENALTY_AREA_LENGTH, PITCH_LENGTH / 2.0,
                  -PENALTY_AREA_WIDTH / 2.0, PENALTY_AREA_WIDTH / 2.0);
  M_our_goal_area =
      Rectangular(-PITCH_LENGTH / 2.0, -PITCH_LENGTH / 2.0 + GOAL_AREA_LENGTH,
                  -GOAL_AREA_WIDTH / 2.0, GOAL_AREA_WIDTH / 2.0);
  M_opp_goal_area =
      Rectangular(PITCH_LENGTH / 2.0 - GOAL_AREA_LENGTH, PITCH_LENGTH / 2.0,
                  -GOAL_AREA_WIDTH / 2.0, GOAL_AREA_WIDTH / 2.0);

  M_our_left_goal_kick_point = M_our_goal_area.TopRightCorner();
  M_our_right_goal_kick_point = M_our_goal_area.BottomRightCorner();
  M_opp_left_goal_kick_point = M_opp_goal_area.TopLeftCorner();
  M_opp_right_goal_kick_point = M_opp_goal_area.BottomLeftCorner();

  M_our_left_goal_post.SetValue(-PITCH_LENGTH / 2.0, -M_goal_width / 2.0);
  M_our_right_goal_post.SetValue(-PITCH_LENGTH / 2.0, M_goal_width / 2.0);
  M_opp_left_goal_post.SetValue(PITCH_LENGTH / 2.0, -M_goal_width / 2.0);
  M_opp_right_goal_post.SetValue(PITCH_LENGTH / 2.0, M_goal_width / 2.0);

  M_pitch_top_left_point = M_pitch_rectanglar.TopLeftCorner();
  M_pitch_bottom_left_point = M_pitch_rectanglar.BottomLeftCorner();
  M_pitch_top_right_point = M_pitch_rectanglar.TopRightCorner();
  M_pitch_bottom_right_point = M_pitch_rectanglar.BottomRightCorner();

  M_our_goal = Vector(-PITCH_LENGTH / 2.0, 0.0);
  M_opp_goal = Vector(PITCH_LENGTH / 2.0, 0.0);

  M_ball_run_dist_with_max_speed = M_ball_speed_max / M_one_minus_ball_decay;
  M_max_tackle_dist =
      Sqrt(M_tackle_dist * M_tackle_dist + M_tackle_width * M_tackle_width);

  M_effort_dec_stamina = M_effort_dec_thr * M_stamina_max;
  M_effort_inc_stamina = M_effort_inc_thr * M_stamina_max;
  M_recover_dec_stamina = M_recover_dec_thr * M_stamina_max;

  M_half_time = M_half_time * 1000 / M_simulator_step;
  M_extra_half_time = M_extra_half_time * 1000 / M_simulator_step;

  M_max_tackle_area = 0.0;
  int exponent = Max(M_foul_exponent, M_tackle_exponent);

  for (double x = 0.0; x <= M_tackle_dist; x += 0.01) {
    for (double y = 0.0; y <= M_tackle_width; y += 0.01) {
      double prob = 1.0 - MinMax(0.0,
                                 pow(x / M_tackle_dist, exponent) +
                                     pow(y / M_tackle_width, exponent),
                                 1.0);

      if (prob > FLOAT_EPS) {
        M_max_tackle_area = Max(M_max_tackle_area, Sqrt(Sqr(x) + Sqr(y)));
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movsd 0x3018(%rdi), %xmm0
movsd 0x3120(%rdi), %xmm1
movsd 0x3118(%rdi), %xmm2
addsd %xmm0, %xmm2
addsd 0x30d8(%rdi), %xmm2
movsd %xmm2, 0x31a8(%rdi)
subsd %xmm0, %xmm1
movsd %xmm1, 0x3128(%rdi)
movsd 0x31b8(%rdi), %xmm1
mulsd 0x20f5e(%rip), %xmm1    # 0x6b878
movsd 0x31b0(%rdi), %xmm0
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4a93e
sqrtsd %xmm0, %xmm0
jmp 0x4a943
callq 0x93c0
movsd %xmm0, 0x3458(%rbx)
movsd 0x30e0(%rbx), %xmm0
movsd 0x206fd(%rip), %xmm1    # 0x6b058
subsd %xmm0, %xmm1
movsd %xmm1, 0x3460(%rbx)
callq 0x93d0
movsd 0x206e4(%rip), %xmm1    # 0x6b058
movsd %xmm0, 0x3468(%rbx)
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rdx, 0x3470(%rbx)
movsd 0x30e0(%rbx), %xmm0
xorl %eax, %eax
mulsd %xmm0, %xmm1
movsd %xmm1, 0x3478(%rbx,%rax,8)
incq %rax
cmpq $0x63, %rax
jne 0x4a997
movq %rdx, 0x3790(%rbx)
xorl %eax, %eax
movq %rax, 0x3798(%rbx)
movabsq $0x404a400000000000, %rcx # imm = 0x404A400000000000
movq %rcx, 0x37a0(%rbx)
movq %rdx, 0x37a8(%rbx)
movq %rax, 0x37b0(%rbx)
movabsq $-0x3fb5c00000000000, %rdx # imm = 0xC04A400000000000
movq %rdx, 0x37b8(%rbx)
movq %rax, 0x37c0(%rbx)
movabsq $-0x4010000000000000, %rdi # imm = 0xBFF0000000000000
movq %rdi, 0x37c8(%rbx)
movabsq $-0x3fbf000000000000, %rsi # imm = 0xC041000000000000
movq %rsi, 0x37d0(%rbx)
movq %rax, 0x37d8(%rbx)
movq %rdi, 0x37e0(%rbx)
movabsq $0x4041000000000000, %rdi # imm = 0x4041000000000000
movq %rdi, 0x37e8(%rbx)
movq %rdx, 0x37f0(%rbx)
movq %rcx, 0x37f8(%rbx)
movq %rsi, 0x3800(%rbx)
movq %rdi, 0x3808(%rbx)
movabsq $-0x3fb6400000000000, %r8 # imm = 0xC049C00000000000
movq %r8, 0x3810(%rbx)
movabsq $0x4049c00000000000, %r8 # imm = 0x4049C00000000000
movq %r8, 0x3818(%rbx)
movabsq $-0x3fbf800000000000, %r8 # imm = 0xC040800000000000
movq %r8, 0x3820(%rbx)
movabsq $0x4040800000000000, %r8 # imm = 0x4040800000000000
movq %r8, 0x3828(%rbx)
movq %rdx, 0x3830(%rbx)
movabsq $-0x3fbe000000000000, %r8 # imm = 0xC042000000000000
movq %r8, 0x3838(%rbx)
movabsq $-0x3fcbd70a3d70a3d7, %r8 # imm = 0xC03428F5C28F5C29
movq %r8, 0x3840(%rbx)
movabsq $0x403428f5c28f5c29, %r9 # imm = 0x403428F5C28F5C29
movq %r9, 0x3848(%rbx)
movabsq $0x4042000000000000, %r10 # imm = 0x4042000000000000
movq %r10, 0x3850(%rbx)
movq %rcx, 0x3858(%rbx)
movq %r8, 0x3860(%rbx)
movq %r9, 0x3868(%rbx)
movq %rdx, 0x3870(%rbx)
movabsq $-0x3fb8800000000000, %r8 # imm = 0xC047800000000000
movq %r8, 0x3878(%rbx)
movabsq $-0x3fddae147ae147ae, %r9 # imm = 0xC02251EB851EB852
movq %r9, 0x3880(%rbx)
movabsq $0x402251eb851eb852, %r10 # imm = 0x402251EB851EB852
movq %r10, 0x3888(%rbx)
movabsq $0x4047800000000000, %r11 # imm = 0x4047800000000000
movq %r11, 0x3890(%rbx)
movq %rcx, 0x3898(%rbx)
movq %r9, 0x38a0(%rbx)
movq %r10, 0x38a8(%rbx)
movq %r8, 0x38d0(%rbx)
movq %r9, 0x38d8(%rbx)
movq %r8, 0x38e0(%rbx)
movq %r10, 0x38e8(%rbx)
movq %r11, 0x38f0(%rbx)
movq %r9, 0x38f8(%rbx)
movq %r11, 0x3900(%rbx)
movq %r10, 0x3908(%rbx)
movsd 0x3008(%rbx), %xmm0
movsd 0x204eb(%rip), %xmm1    # 0x6b088
mulsd %xmm0, %xmm1
movq %rdx, 0x3910(%rbx)
movsd %xmm1, 0x3918(%rbx)
mulsd 0x20cc0(%rip), %xmm0    # 0x6b878
movq %rdx, 0x3920(%rbx)
movsd %xmm0, 0x3928(%rbx)
movq %rcx, 0x3930(%rbx)
movsd %xmm1, 0x3938(%rbx)
movq %rcx, 0x3940(%rbx)
movsd %xmm0, 0x3948(%rbx)
movq %rdx, 0x3950(%rbx)
movq %rsi, 0x3958(%rbx)
movq %rdx, 0x3960(%rbx)
movq %rdi, 0x3968(%rbx)
movq %rcx, 0x3970(%rbx)
movq %rsi, 0x3978(%rbx)
movq %rcx, 0x3980(%rbx)
movq %rdi, 0x3988(%rbx)
movq %rdx, 0x38b0(%rbx)
movq %rax, 0x38b8(%rbx)
movq %rcx, 0x38c0(%rbx)
movq %rax, 0x38c8(%rbx)
movsd 0x30f8(%rbx), %xmm1
movsd 0x32f8(%rbx), %xmm0
divsd 0x3460(%rbx), %xmm1
movsd %xmm1, 0x3448(%rbx)
movsd 0x3310(%rbx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jb 0x4ac7d
sqrtsd %xmm0, %xmm0
jmp 0x4ac86
callq 0x93c0
xorpd %xmm2, %xmm2
movsd %xmm0, 0x3450(%rbx)
movsd 0x3048(%rbx), %xmm0
movsd 0x3080(%rbx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x3430(%rbx)
movsd 0x3098(%rbx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x3440(%rbx)
mulsd 0x3060(%rbx), %xmm0
movsd %xmm0, 0x3438(%rbx)
imull $0x3e8, 0x3238(%rbx), %eax # imm = 0x3E8
movl 0x3284(%rbx), %ecx
cltd
idivl %ecx
movl %eax, 0x3238(%rbx)
imull $0x3e8, 0x3388(%rbx), %eax # imm = 0x3E8
cltd
idivl %ecx
movl %eax, 0x3388(%rbx)
movq $0x0, 0x3300(%rbx)
movsd 0x32f8(%rbx), %xmm0
ucomisd %xmm2, %xmm0
jb 0x4ae44
movsd 0x3318(%rbx), %xmm0
maxsd 0x33e0(%rbx), %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movapd %xmm0, -0x40(%rbp)
xorpd %xmm0, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd 0x3310(%rbx), %xmm0
ucomisd 0x20343(%rip), %xmm0    # 0x6b090
jb 0x4ae20
movsd -0x10(%rbp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
xorpd %xmm1, %xmm1
movsd %xmm1, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
divsd 0x32f8(%rbx), %xmm0
movaps -0x40(%rbp), %xmm1
callq 0x98a0
movsd %xmm0, -0x28(%rbp)
movsd -0x18(%rbp), %xmm0
divsd 0x3310(%rbx), %xmm0
movaps -0x40(%rbp), %xmm1
callq 0x98a0
addsd -0x28(%rbp), %xmm0
maxsd 0x202e8(%rip), %xmm0    # 0x6b090
movsd 0x202a8(%rip), %xmm2    # 0x6b058
movapd %xmm2, %xmm1
minsd %xmm0, %xmm1
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
movsd -0x18(%rbp), %xmm1
ucomisd 0x20273(%rip), %xmm0    # 0x6b040
jbe 0x4ae06
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd -0x20(%rbp), %xmm0
ucomisd 0x202ac(%rip), %xmm0    # 0x6b090
jb 0x4adec
sqrtsd %xmm0, %xmm0
jmp 0x4adf6
callq 0x93c0
movsd -0x18(%rbp), %xmm1
maxsd 0x3300(%rbx), %xmm0
movsd %xmm0, 0x3300(%rbx)
addsd 0x20932(%rip), %xmm1    # 0x6b740
movsd 0x3310(%rbx), %xmm0
ucomisd %xmm1, %xmm0
jae 0x4ad65
movsd -0x10(%rbp), %xmm1
addsd 0x20913(%rip), %xmm1    # 0x6b740
movsd 0x32f8(%rbx), %xmm0
movsd %xmm1, -0x10(%rbp)
ucomisd %xmm1, %xmm0
jae 0x4ad3d
addq $0x38, %rsp
popq %rbx
popq %rbp
retq
nop