Bee fix ausearch (#603)

* Fixing ausearch

* changed stepres

* this works

* blacked

* No more cipheycore in ausearch
This commit is contained in:
Brandon 2021-04-13 20:00:38 +01:00 committed by GitHub
parent 1ebec53cf5
commit f7d21ce099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 14 deletions

View File

@ -6,7 +6,6 @@ from dataclasses import dataclass
from functools import lru_cache
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
import cipheycore
from loguru import logger
from ciphey.iface import (
@ -102,9 +101,7 @@ class Node:
def convert_edge_info(info: CrackInfo):
return cipheycore.ausearch_edge(
info.success_likelihood, info.success_runtime, info.failure_runtime
)
return 1
@dataclass
@ -113,7 +110,7 @@ class Edge:
route: Union[Cracker, Decoder]
dest: Optional[Node] = None
# Info is not filled in for Decoders
info: Optional[cipheycore.ausearch_edge] = None
PriorityType = TypeVar("PriorityType")
@ -186,7 +183,7 @@ class AuSearch(Searcher):
for i in self.get_crackers_for(type(res)):
inst = self._config()(i)
additional_work.append(
Edge(source=node, route=inst, info=convert_edge_info(inst.getInfo(res)))
Edge(source=node, route=inst)
)
priority = min(node.depth, self.priority_cap)
if self.invert_priority:
@ -246,7 +243,6 @@ class AuSearch(Searcher):
break
# Get the highest level result
chunk = self.work.get_work_chunk()
infos = [i.info for i in chunk]
# Work through all of this level's results
while len(chunk) != 0:
max_depth = 0
@ -259,15 +255,13 @@ class AuSearch(Searcher):
# chunk += self.work.get_work_chunk()
# infos = [i.info for i in chunk]
logger.trace(f"{len(infos)} remaining on this level")
step_res = cipheycore.ausearch_minimise(infos)
edge: Edge = chunk.pop(step_res.index)
step_res = 0.1
edge: Edge = chunk.pop(0)
logger.trace(
f"Weight is currently {step_res.weight} "
f"Weight is currently {0} "
f"when we pick {type(edge.route).__name__.lower()} "
f"with depth {edge.source.depth}"
)
del infos[step_res.index]
# Expand the node
res = edge.route(edge.source.level.result.value)

View File

@ -123,8 +123,8 @@ def test_binary_base64_caesar():
def test_braille():
res = decrypt(
Config.library_default().complete_config(),
"⠓⠑⠇⠇⠕⠀⠍⠽⠀⠝⠁⠍⠑⠀⠊⠎⠀⠃⠑⠑⠀⠁⠝⠙⠀⠊⠀⠇⠊⠅⠑⠀⠙⠕⠛⠀⠁⠝⠙⠀⠁⠏⠏⠇⠑⠀⠁⠝⠙⠀⠞⠗⠑⠑"
Config.library_default().complete_config(),
"⠓⠑⠇⠇⠕⠀⠍⠽⠀⠝⠁⠍⠑⠀⠊⠎⠀⠃⠑⠑⠀⠁⠝⠙⠀⠊⠀⠇⠊⠅⠑⠀⠙⠕⠛⠀⠁⠝⠙⠀⠁⠏⠏⠇⠑⠀⠁⠝⠙⠀⠞⠗⠑⠑",
)
assert res.lower() == answer_str.lower()