add solved pages to interrupt db
This commit is contained in:
@@ -14,12 +14,15 @@ class InterruptDB(object):
|
||||
def make(self, keylen):
|
||||
def fn(x):
|
||||
return Probability.IC_w_keylen(x, keylen)
|
||||
score, intrpts = self.iguess.sequential(fn, startAt=0, maxdepth=99)
|
||||
# score, intrpts = self.iguess.genetic(fn, topDown=False, maxdepth=4)
|
||||
# score, intrpts = fn(self.iguess.join()), [[]] # without interrupts
|
||||
for i, skips in enumerate(intrpts):
|
||||
intrpts[i] = self.iguess.to_occurrence_index(skips)
|
||||
return score, intrpts
|
||||
if keylen == 0:
|
||||
keylen = 1
|
||||
score, skips = fn(self.iguess.join()), [[]] # without interrupts
|
||||
else:
|
||||
score, skips = self.iguess.sequential(fn, startAt=0, maxdepth=99)
|
||||
# score, skips = self.iguess.genetic(fn, topDown=False, maxdepth=4)
|
||||
for i, interrupts in enumerate(skips):
|
||||
skips[i] = self.iguess.to_occurrence_index(interrupts)
|
||||
return score, skips
|
||||
|
||||
@staticmethod
|
||||
def load():
|
||||
@@ -48,19 +51,20 @@ class InterruptDB(object):
|
||||
f.write(t)
|
||||
|
||||
|
||||
def populate_db(irp_chars=range(1), startkeylen=1, maxkeylen=32):
|
||||
def populate_db(irp_chars=range(1), startkeylen=1, maxkeylen=32, max_irp=20):
|
||||
oldDB = InterruptDB.load()
|
||||
oldValues = {k: set((a, b, c) for a, _, b, c, _ in v)
|
||||
for k, v in oldDB.items()}
|
||||
for name in [
|
||||
# '0_welcome', 'jpg107-167', '0_warning', '0_wisdom',
|
||||
# '0_warning', '0_welcome', '0_wisdom', '0_koan_1', 'jpg107-167',
|
||||
# '0_loss_of_divinity', 'jpg229', 'p56_an_end', 'p57_parable',
|
||||
'p0-2', 'p3-7', 'p8-14', 'p15-22', 'p23-26',
|
||||
'p27-32', 'p33-39', 'p40-53', 'p54-55'
|
||||
]:
|
||||
fname = f'pages/{name}.txt'
|
||||
print('load:', fname)
|
||||
for irp in irp_chars: # interrupt rune index
|
||||
data = load_indices(fname, irp, maxinterrupt=20)
|
||||
data = load_indices(fname, irp, maxinterrupt=max_irp)
|
||||
db = InterruptDB(data, irp)
|
||||
irp_count = db.stop_count
|
||||
print('analyze interrupt:', irp, 'count:', irp_count)
|
||||
@@ -72,3 +76,6 @@ def populate_db(irp_chars=range(1), startkeylen=1, maxkeylen=32):
|
||||
print(f'{keylen}: {score:.4f}, solutions: {len(interrupts)}')
|
||||
for x in interrupts:
|
||||
InterruptDB.write(name, score, irp, irp_count, keylen, x)
|
||||
|
||||
|
||||
# populate_db(startkeylen=0, maxkeylen=0, max_irp=None)
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
# file-name | number of interrupts | score | interrupt-rune (index) | key length | interrupts (starting with index 1 for first occurrence)
|
||||
0_welcome|25|1.17420|0|1|
|
||||
jpg107-167|5|1.13036|0|1|
|
||||
0_warning|1|1.85685|0|1|
|
||||
0_welcome|25|1.17420|0|1|
|
||||
0_wisdom|5|1.52270|0|1|
|
||||
0_koan_1|25|1.90479|0|1|
|
||||
0_loss_of_divinity|8|1.77524|0|1|
|
||||
jpg107-167|5|1.13036|0|1|
|
||||
jpg229|2|1.66624|0|1|
|
||||
p56_an_end|5|0.94230|0|1|
|
||||
p57_parable|3|1.81859|0|1|
|
||||
p0-2|34|0.98839|0|1|
|
||||
p3-7|26|1.00438|0|1|
|
||||
p8-14|66|0.99935|0|1|
|
||||
|
||||
@@ -60,10 +60,15 @@ def break_cipher(fname, candidates, solver, key_fn):
|
||||
#########################################
|
||||
|
||||
for fname in [
|
||||
# '0_welcome', # V8
|
||||
# 'jpg107-167', # V13
|
||||
# '0_warning', # invert
|
||||
# '0_wisdom', # plain
|
||||
'0_warning', # invert
|
||||
'0_welcome', # V8
|
||||
'0_wisdom', # plain
|
||||
'0_koan_1', # invert + shift
|
||||
'0_loss_of_divinity', # plain
|
||||
'jpg107-167', # V13
|
||||
'jpg229', # plain
|
||||
'p56_an_end', # totient
|
||||
'p57_parable', # plain
|
||||
# 'p0-2', # ???
|
||||
# 'p3-7', # ???
|
||||
# 'p8-14', # ??? -> kl 11? or 12?
|
||||
@@ -72,7 +77,7 @@ for fname in [
|
||||
# 'p27-32', # ???
|
||||
# 'p33-39', # ???
|
||||
# 'p40-53', # ???
|
||||
'p54-55', # ???
|
||||
# 'p54-55', # ???
|
||||
]:
|
||||
# NGramShifter().guess(data, 'ᚠ')
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user