cli
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
PYTHONPATH=src sage src/tea3/tea3model.py
|
||||
PYTHONPATH=src sage src/tea3/cli.py
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
from tea3.pretty_print import pretty_print
|
||||
from tea3.tea3model import Tea3Model
|
||||
|
||||
|
||||
def prompt_int(message: str, lo: int, hi: int) -> int:
|
||||
while True:
|
||||
raw = input(message).strip()
|
||||
try:
|
||||
value = int(raw)
|
||||
except ValueError:
|
||||
print("Please enter a whole number.")
|
||||
continue
|
||||
if lo <= value <= hi:
|
||||
return value
|
||||
print(f"Value must be between {lo} and {hi} (inclusive).")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("=" * 50)
|
||||
print(" Tea3 Model ")
|
||||
print("=" * 50)
|
||||
|
||||
steps = prompt_int("\nHow many steps do you want to run? (1–100): ", 1, 100)
|
||||
|
||||
print("\nR registers are indexed 0–7; bits within each register are 0–7.")
|
||||
reg = prompt_int("Which R register do you want to inspect? (0–7): ", 0, 7)
|
||||
bit = prompt_int("Which bit of that register? (0–7): ", 0, 7)
|
||||
|
||||
print(f"\nRunning {steps} step(s), watching R[{reg}][{bit}]")
|
||||
print("-" * 50)
|
||||
|
||||
model = Tea3Model(max_steps=steps)
|
||||
|
||||
for i in range(steps):
|
||||
model.step()
|
||||
poly = model.R_bits[reg][bit]
|
||||
print(f"\n[Step {i}] R_bits[{reg}][{bit}] =")
|
||||
print(pretty_print(poly))
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print("Done.")
|
||||
|
||||
|
||||
main()
|
||||
@@ -157,11 +157,3 @@ def F32(X, Y):
|
||||
x3*x4*y4 + x3*x4 + x3*y3 + x3*y4 + x4*y3*y4 + x4*y3 + x4 + y3*y4 + y3 + y4,
|
||||
x4*x5*y5 + x4*y4*y5 + x4*y4 + x5*y4*y5 + x5 + y4 + y5 + 1,
|
||||
]
|
||||
|
||||
|
||||
step = 5
|
||||
t = Tea3Model(step)
|
||||
for i in range(step):
|
||||
print("step "+str(i))
|
||||
t.step()
|
||||
print(pretty_print(t.R_bits[0][0]))
|
||||
|
||||
Reference in New Issue
Block a user