Exemple #1
0
def choose_node_index_with_leaf_probability(tree, node_selection_leaf_probability):
    '''
    Returns an index into tree, choosing a leaf with probability
    node-selection-leaf-probability.
    '''
    if type(tree) == list:
        if random_push.lrand() > node_selection_leaf_probability:
            allItems = util.all_items(tree)
            itemsWithCount = []
            for i in range(len(allItems)):
                itemsWithCount.apped([allItems[i], i])
            listItems = []
            for i in itemsWithCount:
                if type(i) == list:
                    listItems.append(i)
            return(random_push.lrand_nth(listItems)[1])
    else:
        return 0
Exemple #2
0
print('FINAL:')
print('======')
pushstate.state_pretty_print(final_state)
'''
#'''
# Testing Code Generation #
###########################
import random_push
import interpreter
import Pysh.pushstate


#print random_push.decompose(100, 100)

atom_generators = Pysh.pushstate.registered_instructions
atom_generators.append([random_push.lrand_int(100), random_push.lrand()])
#print atom_generators

random_code = random_push.random_code(50, atom_generators)
print random_code
print

starting_state = Pysh.pushstate.make_push_state()
final_state = interpreter.run_push(random_code, starting_state, True, True, True, False)
#'''
'''
starting_state = pushstate.make_push_state()

starting_code = '("Hello World" string_contained)'
final_state = interpreter.run_push(starting_code, starting_state, True, True, True, True)
'''