Create a Genome Topology for your Agent
In order to create a agent you first need to create its genome. An agent’s genome is very much like a genome in biology where it is an organism’s complete set of genetic instructions. In this case, the genome is for an AI agent. A genome can be created manually, algorithmically, or using the Intelligent Artifacts Lab GUI (Lab). For now let’s a genome that is located in the config folder named, ‘demo-all.’ All you need to do is upload the Genome in the Lab’s Topology Creator. Moreover, a genome can be downloaded and uploaded for later use or sharing after spawning an agent (covered in the next section below). The genome file is a JavaScript Object Notation (JSON) string that can be imported as below:
[10]:
from ia.gaius.genome_info import Genome
import json
genome_topology = '''{"elements":{"nodes":[{"data":{"name":"P1","id":"p7ae0a0612","type":"primitive","sources":["observables"],"manipulatives":[],"always_update_frequencies":false,"auto_act_method":"none","auto_act_threshold":0.8,"auto_learn_method":"none","classifier":"CVC","datastore":"mongodb","dynamic_sequence_length":true,"max_sequence_length":0,"sort":true,"process_predictions":true,"quiescence":3,"search_depth":10,"recall_threshold":0.1,"smoothness":3,"max_predictions":100,"persistence":5},"position":{"x":587,"y":272.5975},"group":"nodes","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":false,"classes":""},{"data":{"name":"P2","id":"p5b55a8399","type":"primitive","sources":["m44ee0fd21"],"manipulatives":["m44ee0fd21"],"always_update_frequencies":false,"auto_act_method":"none","auto_act_threshold":0.8,"auto_learn_method":"none","classifier":"CVC","datastore":"mongodb","dynamic_sequence_length":true,"max_sequence_length":0,"sort":true,"process_predictions":true,"quiescence":3,"search_depth":10,"recall_threshold":0.1,"smoothness":3,"max_predictions":100,"persistence":5},"position":{"x":687,"y":272.5975},"group":"nodes","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":false,"classes":""},{"data":{"name":"P3","id":"p85643c122","type":"primitive","sources":["observables"],"manipulatives":["mb94faab95"],"always_update_frequencies":false,"auto_act_method":"none","auto_act_threshold":0.8,"auto_learn_method":"none","classifier":"CVC","datastore":"mongodb","dynamic_sequence_length":true,"max_sequence_length":0,"sort":true,"process_predictions":true,"quiescence":3,"search_depth":10,"recall_threshold":0.1,"smoothness":3,"max_predictions":100,"persistence":5},"position":{"x":789,"y":271.5975},"group":"nodes","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":false,"classes":""},{"data":{"displayName":"Multiplier","mtype":"normal","name":"emotiveMultiplier","inputs":["strings","emotives","vectors"],"outputs":["strings","emotives","vectors","predictions"],"description":"Multiplies emotive values by a configurable value.","tags":["emotives","multiply","multiplication","multi","value","factor"],"category":"emotives","genes":{"sources":{"alleles":[],"mutability":0,"value":["observables"],"volatility":0},"multiplier":{"alleles":[1,2,3,4,5,6,7,8,9,10],"mutability":0,"value":5,"volatility":0}},"id":"m44ee0fd21","type":"manipulative","primitive":"p5b55a8399"},"position":{"x":687,"y":372.5975},"group":"nodes","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":false,"classes":""},{"data":{"displayName":"abstraction","name":"abstraction","category":"standard","mtype":"output","description":"Output manipulative to forward abstracted predictions to other Primitives. The chosen field of the predictions are forwarded as. The are also forwarded. No are forwarded.","tags":["abstraction","name","present","past","future","missing","matches","extras","output","forward","abstract","emotives","strings","emotive","classification"],"genes":{"sources":{"alleles":[],"mutability":0,"value":["cognition-data"],"volatility":0},"primitives":{"alleles":[],"mutability":0,"value":["pc4dff12d6"],"volatility":0},"field":{"alleles":["name","past","present","future","missing","extras","matches","classification"],"mutability":0,"value":["name"],"volatility":0}},"id":"mb94faab95","type":"manipulative","primitive":"p85643c122"},"position":{"x":789,"y":171.59750000000003},"group":"nodes","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":false,"classes":""},{"data":{"name":"P4","id":"pc4dff12d6","type":"primitive","sources":["observables"],"manipulatives":[],"always_update_frequencies":false,"auto_act_method":"none","auto_act_threshold":0.8,"auto_learn_method":"none","classifier":"CVC","datastore":"mongodb","dynamic_sequence_length":true,"max_sequence_length":0,"sort":true,"process_predictions":true,"quiescence":3,"search_depth":10,"recall_threshold":0.1,"smoothness":3,"max_predictions":100,"persistence":5},"position":{"x":788,"y":81.59750000000003},"group":"nodes","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":false,"classes":""}],"edges":[{"data":{"id":"eb7965422f","source":"m44ee0fd21","target":"p5b55a8399","type":"edge"},"position":{"x":0,"y":0},"group":"edges","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":true,"classes":""},{"data":{"id":"ec26380337","source":"p85643c122","target":"mb94faab95","type":"edge"},"position":{"x":0,"y":0},"group":"edges","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":true,"classes":"abstractionEdge"},{"data":{"id":"e5dd3a5044","source":"mb94faab95","target":"pc4dff12d6","type":"edge"},"position":{"x":0,"y":0},"group":"edges","removed":false,"selected":false,"selectable":false,"locked":false,"grabbable":true,"pannable":true,"classes":"abstractionEdge"}]},"style":[{"selector":"edge","style":{"target-arrow-shape":"triangle","curve-style":"straight","control-point-distances":10,"control-point-weights":0.1,"width":1,"overlay-color":"#fff"}},{"selector":"edge.curved","style":{"curve-style":"bezier"}}],"data":{},"zoomingEnabled":true,"userZoomingEnabled":true,"zoom":1,"minZoom":1e-50,"maxZoom":1,"panningEnabled":true,"userPanningEnabled":true,"pan":{"x":0,"y":0},"boxSelectionEnabled":false,"renderer":{"name":"canvas"},"wheelSensitivity":0.1,"motionBlur":false,"agent":"demo-all","description":"tutorial"}'''
genome = Genome(json.loads(genome_topology))
Parameter values in genomes are intended to be modified. Since the genome file is a JSON object, modifying values is easy. You can also use the Genome object class to easily find nodes and values for modification.
The following example will change the 'recall_threshold'
and 'max_predictions'
of the primitive ‘P1’:
[20]:
for p in genome.primitives.values():
if p['name'] == 'P1':
p['recall_threshold'] = 0.1
p['max_predictions'] = 10
print("%s: \
\n ID : %s \
\n Recall Threshold : %s \
\n Max Predictions : %s" %(p['name'], p['id'], p['recall_threshold'], p['max_predictions']))
P4:
ID : pc4dff12d6
Recall Threshold : 0.1
Max Predictions : 100
[ ]: