From 6f9fe2078bbe6b80858a053bb1c075690d16ca10 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Mon, 21 Jul 2025 18:26:50 +1000 Subject: [PATCH] Fix a bug in /scripts/circuits.py where it could use symbol again during search --- scripts/circuits.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/circuits.py b/scripts/circuits.py index 6371a71..287c13b 100755 --- a/scripts/circuits.py +++ b/scripts/circuits.py @@ -383,8 +383,10 @@ for circuit_find, circuit_replace, circuit_internal in CIRCUITS: if tt == at and len(t) == len(a): #print('trying symbol', i, j) circuit_symbols[i] = j + symbol_actual[0] = -1 # delete symbol during search match(1, (0, t, a, stack)) #print('failed symbol', i, j) + symbol_actual[0] = at # reinstate symbol on backtrack circuit_symbols[i] = -1 # not really necessary return @@ -469,18 +471,16 @@ for circuit_find, circuit_replace, circuit_internal in CIRCUITS: if tt == at and len(t) == len(a): #print('trying symbol', 0, i) circuit_symbols[0] = i + symbol_actual[0] = -1 # delete symbol during search try: match(1, (0, t, a, stack)) #print('failed symbol', 0, i) + symbol_actual[0] = at # reinstate symbol on backtrack circuit_symbols[0] = -1 # not really necessary except Match: # block is taken from last template symbol (often the output) block = symbols[circuit_symbols[-1]][1] - # delete old symbols - for j in circuit_symbols: - symbols[j][0] = -1 - # add new symbols for symbol_type, template in circuit_replace: symbols.append((symbol_type, block, substitute(template))) -- 2.34.1