谢谢clippy老师

This commit is contained in:
shenjack-5600u 2024-04-28 20:34:39 +08:00
parent 2f416cb153
commit 56101df85e
Signed by: shenjack
GPG Key ID: FDF9864E11C7E79F
5 changed files with 50 additions and 53 deletions

2
Cargo.lock generated
View File

@ -1831,7 +1831,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "tswn"
version = "0.1.9"
version = "0.1.10"
dependencies = [
"base16384",
"chrono",

View File

@ -1,7 +1,7 @@
[package]
name = "tswn"
description = "tool shenjack work shop namerena"
version = "0.1.9"
version = "0.1.10"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -63,7 +63,7 @@ pub fn cacl(config: CacluateConfig, id: u64, outfile: &PathBuf) {
let prop = namer.get_property();
k += 1;
if k >= report_interval as u64 {
if k >= report_interval {
let now = std::time::Instant::now();
let d_t: std::time::Duration = now.duration_since(start_time);
let new_run_speed = k as f64 / d_t.as_secs_f64();
@ -101,26 +101,27 @@ pub fn cacl(config: CacluateConfig, id: u64, outfile: &PathBuf) {
}
if prop > config.prop_expect as f32 {
let name = gen_name(i as u64);
let name = gen_name(i);
let full_name = format!("{}@{}", name, config.team);
// 虚评
namer.update_skill();
let xu = crate::evaluate::xuping::XuPing2_0_1015::evaluate(&namer);
let xu_qd = crate::evaluate::xuping::XuPing2_0_1015_QD::evaluate(&namer);
if xu < config.qp_expect as f64 {
if xu < config.qp_expect as f64 && xu_qd < config.qp_expect as f64{
continue;
}
let xu_qd = crate::evaluate::xuping::XuPing2_0_1015_QD::evaluate(&namer);
get_count += 1;
info!("Id:{:>15}|{}|{}|{}", i, full_name, xu, namer.get_info());
info!("Id:{:>15}|{}|{:.4}|{:.4}|{}", i, full_name, xu, xu_qd, namer.get_info());
let write_in = format!(
// <full_name>,<xu>,<xuqd>,<namer.get_info()>
"{},{},{},{}\n",
// <full_name>,<id>,<xu>,<xuqd>,<namer.get_info()>
"{},{:>15},{:.4},{:.4},{}\n",
full_name,
i,
xu,
xu_qd,
namer.get_info_csv()

View File

@ -19,8 +19,11 @@ pub fn predict_13(name: &Namer) -> f64 {
let mut combined_skills: [f64; 43] = [0.0; 43];
// 长度取 64, 方便simd填充
for i in 0..8 {
combined_skills[i] = name.name_prop[i] as f64;
// for i in 0..8 {
// combined_skills[i] = name.name_prop[i] as f64;
// }
for (i, prop) in combined_skills.iter_mut().enumerate().take(8) {
*prop = name.name_prop[i] as f64;
}
for i in 0..16 {
if name.skl_freq[i] != 0 {
@ -122,7 +125,7 @@ pub fn predict_13(name: &Namer) -> f64 {
pub fn poly(input: &[f64; 44]) -> [f64; 1034] {
let mut result = [0.0; 1034];
for index in 0..1034 {
let mut l: i32 = 44;
let l: i32 = 44;
let mut i: i32 = 0;
let mut p: i32 = 0;
let mut q: i32 = 0;
@ -171,8 +174,11 @@ if (x[42] > 0) x[42] += 20
*/
pub fn predict_20(name: &Namer) -> f64 {
let mut st: [f64; 44] = [0.0; 44];
for i in 0..8 {
st[i] = name.name_prop[i] as f64;
// for i in 0..8 {
// st[i] = name.name_prop[i] as f64;
// }
for (i, prop) in st.iter_mut().enumerate().take(8) {
*prop = name.name_prop[i] as f64;
}
for i in 0..16 {
if name.skl_freq[i] != 0 {
@ -181,7 +187,7 @@ pub fn predict_20(name: &Namer) -> f64 {
}
if st[32] > 0.0 {
let mut shadow_name = Namer::new_unchecked(&format!("{}?shadow@{}", name.name, name.team));
let shadow_name = Namer::new_unchecked(&format!("{}?shadow@{}", name.name, name.team));
let mut shadow_sum = shadow_name.name_prop[0] as f64 / 3.0;
for j in 1..8 {
@ -190,7 +196,7 @@ pub fn predict_20(name: &Namer) -> f64 {
shadow_sum -= (shadow_name.name_prop[7] as f64 - 36.0) * 3.0;
let mut shadowi = shadow_sum - 210.0;
shadowi = shadowi * st[32] as f64 / 100.0;
shadowi = shadowi * st[32] / 100.0;
st[43] = shadowi;
} else {
st[43] = 0.0;
@ -203,24 +209,21 @@ pub fn predict_20(name: &Namer) -> f64 {
let xp = poly(&st);
let mut sum = xuping20::BASE;
let mut sum_qd = xuping20::BASE_QD;
let mut _sum_qd = xuping20::BASE_QD;
for i in 0..1034 {
unsafe {
sum += xp.get_unchecked(i) * xuping20::MODEL.get_unchecked(i);
unsafe {
for (i, xp) in xp.iter().enumerate() {
sum += xp * xuping20::MODEL.get_unchecked(i);
}
}
// for i in 0..1034 {
// sum_qd += xp[i] * xuping20::MODEL_QD[i];
// }
sum
}
pub fn predict_20_qd(name: &Namer) -> f64 {
let mut st: [f64; 44] = [0.0; 44];
for i in 0..8 {
st[i] = name.name_prop[i] as f64;
for (i, prop) in st.iter_mut().enumerate().take(8) {
*prop = name.name_prop[i] as f64;
}
for i in 0..16 {
if name.skl_freq[i] != 0 {
@ -229,7 +232,7 @@ pub fn predict_20_qd(name: &Namer) -> f64 {
}
if st[32] > 0.0 {
let mut shadow_name = Namer::new_unchecked(&format!("{}?shadow@{}", name.name, name.team));
let shadow_name = Namer::new_unchecked(&format!("{}?shadow@{}", name.name, name.team));
let mut shadow_sum = shadow_name.name_prop[0] as f64 / 3.0;
for j in 1..8 {
@ -238,7 +241,7 @@ pub fn predict_20_qd(name: &Namer) -> f64 {
shadow_sum -= (shadow_name.name_prop[7] as f64 - 36.0) * 3.0;
let mut shadowi = shadow_sum - 210.0;
shadowi = shadowi * st[32] as f64 / 100.0;
shadowi = shadowi * st[32] / 100.0;
st[43] = shadowi;
} else {
st[43] = 0.0;
@ -252,8 +255,8 @@ pub fn predict_20_qd(name: &Namer) -> f64 {
let mut sum_qd = xuping20::BASE_QD;
for i in 0..1034 {
sum_qd += xp[i] * xuping20::MODEL_QD[i];
for (i, xp) in xp.iter().enumerate() {
sum_qd += xp * xuping20::MODEL_QD[i];
}
sum_qd

View File

@ -50,7 +50,7 @@ impl TeamNamer {
}
}
#[inline(always)]
pub fn clone_vals(&self) -> [u8; 256] { self.val.clone() }
pub fn clone_vals(&self) -> [u8; 256] { self.val }
}
#[derive(Debug, Clone)]
@ -64,6 +64,7 @@ pub struct Namer {
pub skl_freq: [u8; 40],
}
#[allow(dead_code)]
impl Namer {
/// 最完整的、最简单的 new
/// 可以直接丢一个 name 进来
@ -150,7 +151,7 @@ impl Namer {
// simd 优化
#[cfg(feature = "simd")]
{
let mut simd_val = val.clone();
let mut simd_val = val;
let mut simd_val_b = [0_u8; 256];
let simd_181 = u8x64::splat(181);
let simd_160 = u8x64::splat(160);
@ -236,7 +237,7 @@ impl Namer {
+ *prop_name.get_unchecked(4) as u32
+ *prop_name.get_unchecked(5) as u32
+ *prop_name.get_unchecked(6) as u32;
*name_prop.get_unchecked_mut(1) = median(
*prop_name.get_unchecked(10),
*prop_name.get_unchecked(11),
@ -303,8 +304,8 @@ impl Namer {
#[cfg(feature = "simd")]
{
let mut simd_val = self.val.clone();
let mut simd_val_b = self.val.clone();
let mut simd_val = self.val;
let mut simd_val_b = self.val;
let simd_181 = u8x64::splat(181);
let simd_199 = u8x64::splat(199);
let simd_128 = u8x64::splat(128);
@ -316,8 +317,8 @@ impl Namer {
unsafe {
let mut x = u8x64::from_slice(simd_val.get_unchecked(i..));
let mut y = u8x64::from_slice(simd_val_b.get_unchecked(i..));
x = x * simd_181 + simd_199 & simd_128;
y = y * simd_53 & simd_63 ^ simd_32;
x = (x * simd_181 + simd_199) & simd_128;
y = (y * simd_53) & simd_63 ^ simd_32;
x.copy_to_slice(simd_val.get_unchecked_mut(i..));
y.copy_to_slice(simd_val_b.get_unchecked_mut(i..));
}
@ -362,11 +363,10 @@ impl Namer {
}
}
let mut last = -1;
let mut j = 0;
for i in (64..128).step_by(4) {
for (j, i) in (64..128).step_by(4).enumerate() {
let p = unsafe {
min(
min(*self.name_base.get_unchecked(i + 0), *self.name_base.get_unchecked(i + 1)),
min(*self.name_base.get_unchecked(i), *self.name_base.get_unchecked(i + 1)),
min(*self.name_base.get_unchecked(i + 2), *self.name_base.get_unchecked(i + 3)),
)
};
@ -378,7 +378,6 @@ impl Namer {
} else {
self.skl_freq[j] = 0
}
j += 1;
}
if last != -1 {
self.skl_freq[last as usize] <<= 1;
@ -401,17 +400,15 @@ impl Namer {
#[inline(always)]
pub fn get_property(&self) -> f32 {
let sum1 = self.name_prop[1..=7].iter().sum::<u32>();
let sum2 = self.name_prop[0] as u32;
let sum2 = self.name_prop[0];
sum1 as f32 + (sum2 as f32 / 3_f32)
}
pub fn get_净化(&self) -> u8 {
// self.skl_freq[17]
for (i, v) in self.skl_freq.iter().enumerate() {
if *v != 0 {
if self.skl_id[i] == 17 {
return *v;
}
if *v != 0 && self.skl_id[i] == 17 {
return *v;
}
}
0
@ -420,10 +417,8 @@ impl Namer {
pub fn get_分身(&self) -> u8 {
// self.skl_freq[23]
for (i, v) in self.skl_freq.iter().enumerate() {
if *v != 0 {
if self.skl_id[i] == 23 {
return *v;
}
if *v != 0 && self.skl_id[i] == 23 {
return *v;
}
}
0
@ -432,10 +427,8 @@ impl Namer {
pub fn get_幻术(&self) -> u8 {
// self.skl_freq[24]
for (i, v) in self.skl_freq.iter().enumerate() {
if *v != 0 {
if self.skl_id[i] == 24 {
return *v;
}
if *v != 0 && self.skl_id[i] == 24 {
return *v;
}
}
0