他真的很抽象你知道吧(
This commit is contained in:
parent
ed9e2736d6
commit
4969c8cf6b
@ -90,6 +90,7 @@ fn cacl(config: Command, id: u64, outfile: &PathBuf) {
|
||||
// 写入 (写到最后一行)
|
||||
match std::fs::OpenOptions::new()
|
||||
.append(true)
|
||||
.create(true)
|
||||
.open(outfile)
|
||||
.and_then(|mut file| file.write(format!("{}\n", full_name).as_bytes()))
|
||||
{
|
||||
@ -159,10 +160,6 @@ fn main() {
|
||||
if let Err(e) = std::fs::create_dir_all(&out_path.parent().unwrap()) {
|
||||
warn!("创建文件夹失败: {}", e);
|
||||
}
|
||||
// 再创建文件
|
||||
if let Err(e) = std::fs::File::create(&out_path) {
|
||||
warn!("创建文件失败: {}", e);
|
||||
}
|
||||
|
||||
info!("开始: {} 结尾: {}", cli_arg.start, cli_arg.end);
|
||||
info!("线程数: {}", cli_arg.thread_count);
|
||||
|
116
src/name.rs
116
src/name.rs
@ -1,9 +1,8 @@
|
||||
#[cfg(feature = "simd")]
|
||||
use std::simd::u8x64;
|
||||
use std::cmp::min;
|
||||
#[cfg(feature = "simd")]
|
||||
use std::simd::cmp::SimdPartialOrd;
|
||||
#[cfg(feature = "simd")]
|
||||
use std::simd::Simd;
|
||||
use std::simd::u8x64;
|
||||
|
||||
use tracing::warn;
|
||||
|
||||
@ -257,16 +256,11 @@ impl Namer {
|
||||
// 计算 name_prop
|
||||
let mut prop_name = name_base[0..32].to_vec();
|
||||
prop_name[0..10].sort_unstable();
|
||||
/*
|
||||
st[0] = 154 + a[3] + a[4] + a[5] + a[6];
|
||||
st[1] = median(prop_name[10], prop_name[11], prop_name[12]) + 36;
|
||||
st[2] = median(prop_name[13], prop_name[14], prop_name[15]) + 36;
|
||||
st[3] = median(prop_name[16], prop_name[17], prop_name[18]) + 36;
|
||||
st[4] = median(prop_name[19], prop_name[20], prop_name[21]) + 36;
|
||||
st[5] = median(prop_name[22], prop_name[23], prop_name[24]) + 36;
|
||||
st[6] = median(prop_name[25], prop_name[26], prop_name[27]) + 36;
|
||||
st[7] = median(prop_name[28], prop_name[29], prop_name[30]) + 36; */
|
||||
name_prop[0] = 154 + prop_name[3] as u32 + prop_name[4] as u32 + prop_name[5] as u32 + prop_name[6] as u32;
|
||||
name_prop[0] = 154
|
||||
+ prop_name[3] as u32
|
||||
+ prop_name[4] as u32
|
||||
+ prop_name[5] as u32
|
||||
+ prop_name[6] as u32;
|
||||
name_prop[1] = median(prop_name[10], prop_name[11], prop_name[12]) as u32 + 36;
|
||||
name_prop[2] = median(prop_name[13], prop_name[14], prop_name[15]) as u32 + 36;
|
||||
name_prop[3] = median(prop_name[16], prop_name[17], prop_name[18]) as u32 + 36;
|
||||
@ -326,6 +320,13 @@ impl Namer {
|
||||
if (freq[15] && last != 15)
|
||||
freq[15] += std::min(std::min(name_base[62], name_base[63]), freq[15]);
|
||||
} */
|
||||
|
||||
let mut skill_id = [0u8; 40];
|
||||
for i in 0..40 {
|
||||
skill_id[i] = i as u8
|
||||
}
|
||||
|
||||
let mut name_base = self.name_base.clone();
|
||||
#[cfg(feature = "simd")]
|
||||
{
|
||||
let mut simd_val = self.val.clone();
|
||||
@ -345,14 +346,87 @@ impl Namer {
|
||||
x.copy_to_slice(&mut simd_val[i..]);
|
||||
y.copy_to_slice(&mut simd_val_b[i..]);
|
||||
}
|
||||
|
||||
let mut mod_count = 0;
|
||||
for i in 0..256 {
|
||||
if simd_val[i] != 0 {
|
||||
name_base[mod_count as usize] = simd_val_b[i];
|
||||
mod_count += 1;
|
||||
}
|
||||
}
|
||||
// const int N = 256, M = 128, K = 64, skill_cnt = 40, max_len = 25;
|
||||
let mut p: u8 = 0;
|
||||
let mut q: u8 = 0;
|
||||
let mut s: u8 = 0;
|
||||
for _ in 0..2 {
|
||||
for i in 0..40 {
|
||||
/*
|
||||
inline u8_t rnd() {
|
||||
q += val[++p];
|
||||
std::swap(val[p], val[q]);
|
||||
u8_t u = val[(val[p] + val[q]) & 255];
|
||||
q += val[++p];
|
||||
std::swap(val[p], val[q]);
|
||||
return (u << 8 | val[(val[p] + val[q]) & 255]) % skill_cnt;
|
||||
} */
|
||||
let rnd = {
|
||||
q = q.wrapping_add(self.val[p as usize]);
|
||||
p += 1;
|
||||
self.val.swap(p as usize, q as usize);
|
||||
let u: u8 = self.val
|
||||
[((self.val[p as usize] as u16 + self.val[q as usize] as u16) & 255) as usize];
|
||||
q = q.wrapping_add(self.val[p as usize]);
|
||||
p += 1;
|
||||
self.val.swap(p as usize, q as usize);
|
||||
let t = self.val
|
||||
[((self.val[p as usize] as u16 + self.val[q as usize] as u16) & 255) as usize];
|
||||
(((u as u32) << 8 | t as u32) % 40) as u8
|
||||
};
|
||||
// s = (s.wrapping_add(rnd).wrapping_add(skill_id[i])) % 40;
|
||||
s = (s as u16 + rnd as u16 + skill_id[i] as u16) as u8 % 40;
|
||||
skill_id.swap(i as usize, s as usize);
|
||||
}
|
||||
}
|
||||
let mut last = -1;
|
||||
let mut j = 0;
|
||||
for i in (64..128).step_by(4) {
|
||||
// a[k] == self.name_base[k+10]
|
||||
let p = min(
|
||||
min(self.name_base[i + 0], self.name_base[i + 1]),
|
||||
min(self.name_base[i + 2], self.name_base[i + 3]),
|
||||
);
|
||||
if p > 10 && skill_id[j] < 35 {
|
||||
self.skl_freq[j] = p - 10;
|
||||
if skill_id[j] < 25 {
|
||||
last = j as i32;
|
||||
};
|
||||
} else {
|
||||
self.skl_freq[j] = 0
|
||||
}
|
||||
j += 1;
|
||||
}
|
||||
if last != -1 {
|
||||
self.skl_freq[last as usize] <<= 1;
|
||||
// *= 2
|
||||
}
|
||||
if (self.skl_freq[14] != 0) && (last != 14) {
|
||||
self.skl_freq[14] += min(
|
||||
min(self.name_base[60], self.name_base[61]),
|
||||
self.skl_freq[14],
|
||||
);
|
||||
}
|
||||
if (self.skl_freq[15] != 0) && (last != 15) {
|
||||
self.skl_freq[15] += min(
|
||||
min(self.name_base[62], self.name_base[63]),
|
||||
self.skl_freq[15],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "simd"))]
|
||||
{
|
||||
|
||||
todo!("none simd 还没写呢")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@ -416,6 +490,16 @@ mod test {
|
||||
assert_eq!(namer.name_base.to_vec(), base_name_vec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skill_prop_test() {
|
||||
let team = TeamNamer::new_unchecked("x");
|
||||
let mut namer = Namer::new_from_team_namer_unchecked(&team, "x");
|
||||
|
||||
namer.update_skill();
|
||||
println!("namer: {:?}", namer);
|
||||
panic!()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prop_test() {
|
||||
let team = TeamNamer::new_unchecked("x");
|
||||
|
Loading…
Reference in New Issue
Block a user