185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
if isinstance(score[item], tree.Tree): # Also, make this use the find_next_node() function (or whatever I called it)
score_index_to_replace = item
if score_index_to_replace is None:
raise ValueError("No more nodes to fill in")
time_remaining = max_time - score_len(score)
new_phrase, syncs = choose_phrase(instr, syncs, score_len(score), time_remaining, score)
score = score[:score_index_to_replace-1] + new_phrase + score[score_index_to_replace+1:]
except ValueError:
return (score, syncs)
def choose_phrase(instr, syncs, current_time, time_remaining, score):
'''Filters grammars for ones that match the sync option, and phrases that fit the time remaining in the score'''
|
|
|
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
if isinstance(score[item], tree.Tree): # Also, make this use the find_next_node() function (or whatever I called it)
score_index_to_replace = item
if score_index_to_replace is None:
raise ValueError("No more nodes to fill in")
time_remaining = max_time - score_len(score)
new_phrase, syncs = choose_phrase(instr, syncs, score_len(score), time_remaining, score)
score = score[:score_index_to_replace] + new_phrase + score[score_index_to_replace+1:]
except ValueError:
return (score, syncs)
def choose_phrase(instr, syncs, current_time, time_remaining, score):
'''Filters grammars for ones that match the sync option, and phrases that fit the time remaining in the score'''
|