-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvp.py
More file actions
38 lines (29 loc) · 744 Bytes
/
Copy pathmvp.py
File metadata and controls
38 lines (29 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from src.encoder import SubitEncoder
from src.decoder import SubitDecoder
from src.fsm import SubitFSM
import json
# Initial SUBIT‑64 axes (A–F)
axes = {"A": 1, "B": 0, "C": 1, "D": 0, "E": 0, "F": 1}
encoder = SubitEncoder()
decoder = SubitDecoder()
# Encode → 6‑bit integer
value = encoder.encode(axes)
# Decode back into phase flags
decoded = decoder.decode(value)
# FSM transitions
transitions = {
37: { # 100101₂
"observe": 5,
"act": 41
}
}
fsm = SubitFSM(transitions)
# Apply an event
next_state = fsm.next(value, "act")
# Serialize result
payload = {
"state": {"value": value},
"next_state": {"value": next_state},
"decoded": decoded
}
print(json.dumps(payload, indent=2))