mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
perf.优化hash阈值的读取方式
This commit is contained in:
@@ -856,7 +856,9 @@
|
||||
]
|
||||
},
|
||||
"InfrastSkillsHash": {
|
||||
"algorithm": "justReturn",
|
||||
"template": "empty.png",
|
||||
"templThreshold_Doc": "作为哈希距离的阈值使用",
|
||||
"templThreshold": 60,
|
||||
"rectMove_Doc": "基于笑脸的位置移动",
|
||||
"rectMove": [
|
||||
0,
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "Resource.h"
|
||||
#include "RuntimeStatus.h"
|
||||
|
||||
int asst::InfrastProductionTask::m_hash_dist_threshold = 0;
|
||||
|
||||
//bool asst::InfrastProductionTask::run()
|
||||
//{
|
||||
// json::value task_start_json = json::object{
|
||||
@@ -33,6 +35,15 @@
|
||||
// return true;
|
||||
//}
|
||||
|
||||
asst::InfrastProductionTask::InfrastProductionTask(AsstCallback callback, void* callback_arg)
|
||||
: InfrastAbstractTask(callback, callback_arg)
|
||||
{
|
||||
if (m_hash_dist_threshold == 0) {
|
||||
m_hash_dist_threshold = std::dynamic_pointer_cast<MatchTaskInfo>(
|
||||
resource.task().task_ptr("InfrastSkillsHash"))->templ_threshold;
|
||||
}
|
||||
}
|
||||
|
||||
bool asst::InfrastProductionTask::shift_facility_list()
|
||||
{
|
||||
LogTraceFunction;
|
||||
@@ -167,7 +178,7 @@ size_t asst::InfrastProductionTask::opers_detect()
|
||||
m_all_available_opers.cbegin(), m_all_available_opers.cend(),
|
||||
[&cur_info](const InfrastOperSkillInfo& info) -> bool {
|
||||
int dist = utils::hamming(cur_info.hash, info.hash);
|
||||
return dist < HashDistThres;
|
||||
return dist < m_hash_dist_threshold;
|
||||
});
|
||||
// 如果两个的hash距离过小,则认为是同一个干员,不进行插入
|
||||
if (find_iter != m_all_available_opers.cend()) {
|
||||
@@ -306,7 +317,7 @@ bool asst::InfrastProductionTask::optimal_calc()
|
||||
for (const auto& [key, hash] : opt.hashs) {
|
||||
int dist = utils::hamming(find_iter->hash, hash);
|
||||
log.trace("hash dist", dist, hash, find_iter->hash);
|
||||
if (dist < HashDistThres) {
|
||||
if (dist < m_hash_dist_threshold) {
|
||||
hash_matched = true;
|
||||
break;
|
||||
}
|
||||
@@ -414,7 +425,7 @@ bool asst::InfrastProductionTask::opers_choose()
|
||||
[&](const InfrastOperSkillInfo& lhs) -> bool {
|
||||
// 既要技能相同,也要hash相同,双重校验
|
||||
int dist = utils::hamming(lhs.hash, opt_iter->hash);
|
||||
return dist < HashDistThres
|
||||
return dist < m_hash_dist_threshold
|
||||
&& lhs.skills_comb == opt_iter->skills_comb;
|
||||
});
|
||||
if (find_iter == cur_all_info.cend()) {
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace asst
|
||||
class InfrastProductionTask : public InfrastAbstractTask
|
||||
{
|
||||
public:
|
||||
using InfrastAbstractTask::InfrastAbstractTask;
|
||||
InfrastProductionTask(AsstCallback callback, void* callback_arg);
|
||||
virtual ~InfrastProductionTask() = default;
|
||||
//virtual bool run() override;
|
||||
void set_facility(std::string facility_name) noexcept
|
||||
@@ -31,7 +31,7 @@ namespace asst
|
||||
bool opers_choose();
|
||||
InfrastSkillsComb efficient_regex_calc(InfrastSkillsComb skill_info) const;
|
||||
|
||||
constexpr static int HashDistThres = 50;
|
||||
static int m_hash_dist_threshold;
|
||||
|
||||
std::string m_facility;
|
||||
std::string m_product;
|
||||
|
||||
Reference in New Issue
Block a user