diff --git a/Default-Config-jsons/NandProgram100.json b/Default-Config-jsons/NandProgram100.json new file mode 100644 index 00000000..e60d1d29 --- /dev/null +++ b/Default-Config-jsons/NandProgram100.json @@ -0,0 +1,1487 @@ +{ + "value0": [ + { + "operation": "Global Anchor", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "1111111111111111111111111111111111111111111111111111111111111111", + "descriptors": [ + { + "key": "summary", + "value": "register a global jump-to destination, maybe terminate" + }, + { + "key": "tag bits", + "value": "1111111111111111111111111111111111111111111111111111111111111111" + }, + { + "key": "tag moniker", + "value": "sad ibex" + } + ] + }, + { + "operation": "IO", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + }, + { + "operation": "IO", + "args": { + "value0": 1, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + }, + { + "operation": "IO", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + }, + { + "operation": "Nand", + "args": { + "value0": 0, + "value1": 1, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Reproduce", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + } + ] +} \ No newline at end of file diff --git a/Default-Config-jsons/diff-reward-env.json b/Default-Config-jsons/diff-reward-env.json new file mode 100644 index 00000000..6ff8a65f --- /dev/null +++ b/Default-Config-jsons/diff-reward-env.json @@ -0,0 +1,15 @@ +{ + "shared": { + "tasks": [ + {"name": "NAND", "value": 1, "reward_mode": "add"}, + {"name": "NOT", "value": 1, "reward_mode": "add"}, + {"name": "OR_NOT", "value": 2, "reward_mode": "add"}, + {"name": "AND", "value": 2, "reward_mode": "add"}, + {"name": "OR", "value": 4, "reward_mode": "add"}, + {"name": "AND_NOT", "value": 4, "reward_mode": "add"}, + {"name": "NOR", "value": 8, "reward_mode": "add"}, + {"name": "XOR", "value": 8, "reward_mode": "add"}, + {"name": "EQU", "value": 16, "reward_mode": "add"} + ] + } +} \ No newline at end of file diff --git a/example-settings-cfg/NandProgram100.json b/example-settings-cfg/NandProgram100.json index 5e227a9c..88f2aa82 100644 --- a/example-settings-cfg/NandProgram100.json +++ b/example-settings-cfg/NandProgram100.json @@ -7,7 +7,7 @@ "value1": 0, "value2": 0 }, - "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "bitstring": "1111111111111111111111111111111111111111111111111111111111111111", "descriptors": [ { "key": "summary", @@ -15,11 +15,11 @@ }, { "key": "tag bits", - "value": "0000000000000000000000000000000000000000000000000000000000000000" + "value": "1111111111111111111111111111111111111111111111111111111111111111" }, { "key": "tag moniker", - "value": "sad ibex" + "value": "flawed mayfly" } ] }, diff --git a/example-settings-cfg/NotNandProgram100.json b/example-settings-cfg/NotNandProgram100.json index aaf90250..8f7d40cc 100644 --- a/example-settings-cfg/NotNandProgram100.json +++ b/example-settings-cfg/NotNandProgram100.json @@ -7,7 +7,7 @@ "value1": 0, "value2": 0 }, - "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "bitstring": "1111111111111111111111111111111111111111111111111111111111111111", "descriptors": [ { "key": "summary", @@ -15,11 +15,11 @@ }, { "key": "tag bits", - "value": "0000000000000000000000000000000000000000000000000000000000000000" + "value": "1111111111111111111111111111111111111111111111111111111111111111" }, { "key": "tag moniker", - "value": "sad ibex" + "value": "flawed mayfly" } ] }, diff --git a/example-settings-cfg/NotProgram100.json b/example-settings-cfg/NotProgram100.json index 4fa831be..2b5e83ae 100644 --- a/example-settings-cfg/NotProgram100.json +++ b/example-settings-cfg/NotProgram100.json @@ -7,7 +7,7 @@ "value1": 0, "value2": 0 }, - "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "bitstring": "1111111111111111111111111111111111111111111111111111111111111111", "descriptors": [ { "key": "summary", @@ -15,11 +15,11 @@ }, { "key": "tag bits", - "value": "0000000000000000000000000000000000000000000000000000000000000000" + "value": "1111111111111111111111111111111111111111111111111111111111111111" }, { "key": "tag moniker", - "value": "sad ibex" + "value": "flawed mayfly" } ] }, diff --git a/example-settings-cfg/ReproProgram100.json b/example-settings-cfg/ReproProgram100.json index afa02815..d2139506 100644 --- a/example-settings-cfg/ReproProgram100.json +++ b/example-settings-cfg/ReproProgram100.json @@ -7,7 +7,7 @@ "value1": 0, "value2": 0 }, - "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "bitstring": "1111111111111111111111111111111111111111111111111111111111111111", "descriptors": [ { "key": "summary", @@ -15,11 +15,11 @@ }, { "key": "tag bits", - "value": "0000000000000000000000000000000000000000000000000000000000000000" + "value": "1111111111111111111111111111111111111111111111111111111111111111" }, { "key": "tag moniker", - "value": "sad ibex" + "value": "flawed mayfly" } ] }, diff --git a/source/Organism.h b/source/Organism.h index 1ee29efa..3f4f84cd 100644 --- a/source/Organism.h +++ b/source/Organism.h @@ -288,14 +288,6 @@ class Organism { std::cout << "ClearReproSyms called from Organism" << std::endl; throw "Organism method called!"; } - virtual void CycleTransfer(int _in) { - std::cout << "CycleTransfer called from Organism" << std::endl; - throw "Organism method called!"; - } - virtual int GetCyclesGiven() const { - std::cout << "GetCyclesGiven called from Organism" << std::endl; - throw "Organism method called!"; - } //Bacterium functions virtual double ProcessLysogenResources(double phage_inc_val) { std::cout << "ProcessLysogenResources called from Organism" << std::endl; @@ -376,11 +368,5 @@ class Organism { } - //SGPMode Symbiont Functions - virtual float DoTaskInteraction(float score, size_t task_id) { - std::cout << "DoTaskInteraction called from Organism" << std::endl; - throw "Organism method called!"; - } - }; #endif diff --git a/source/sgp_mode/ProgramBuilder.h b/source/sgp_mode/ProgramBuilder.h index df5e385e..905ab06d 100644 --- a/source/sgp_mode/ProgramBuilder.h +++ b/source/sgp_mode/ProgramBuilder.h @@ -641,8 +641,10 @@ class ProgramBuilder { * Note: Warns if the program contains disabled instructions. */ program_t LoadProgramFile(const std::filesystem::path& path) { + program_t program(path); RectifyWithWarning(program); + return program; } diff --git a/source/sgp_mode/SGPConfigSetup.h b/source/sgp_mode/SGPConfigSetup.h index b09d31fe..12f0c14a 100644 --- a/source/sgp_mode/SGPConfigSetup.h +++ b/source/sgp_mode/SGPConfigSetup.h @@ -32,6 +32,11 @@ EMP_EXTEND_CONFIG(SymConfigSGP, SymConfigBase, GROUP(SGP_MUTATION, "SGP mutation group"), VALUE(SGP_MUT_PER_BIT_RATE, double, 0.01, "Per-bit mutation rate for sgp programs"), + GROUP(CUSTOM_PROGRAM, "Custom Program Settings"), + VALUE(HOST_PROGRAM_PATH, std::string, "Default-Config-jsons/NandProgram100.json", "Json file that provides hosts a custom starting program"), + VALUE(SYM_PROGRAM_PATH, std::string, "Default-Config-jsons/NandProgram100.json", "Json file that provides symbionts a custom starting program"), + + GROUP(STRESS, "Stress Settings"), VALUE(ENABLE_STRESS, bool, false, "Stress interactions enabled?"), VALUE(STRESS_TYPE, std::string, "mutualist", "What kind of stress symbionts should be incorporated in stressful environments? (Options: 'mutualist', 'parasite', 'neutral')"), @@ -62,7 +67,7 @@ EMP_EXTEND_CONFIG(SymConfigSGP, SymConfigBase, VALUE(PARASITE_BASE_TASK_VALUE_PROP, double, 0.25, "Proportion of task value (defined by environment) that parasites receive when they fail to interact with their host."), GROUP(TASK_ENVIRONMENT, "Task environment settings"), - VALUE(TASK_ENV_CFG_PATH, std::string, "environment.json", "Json file that provides environment configuration"), + VALUE(TASK_ENV_CFG_PATH, std::string, "Default-Config-jsons/diff-reward-env.json", "Json file that provides environment configuration"), VALUE(TASK_IO_BANK_SIZE, size_t, 100000, "How many possible task input/output combinations to pre-generate?"), VALUE(TASK_IO_UNIQUE_OUTPUT, bool, true, "Should each output in the pregenerated io combinations be unique?"), VALUE(HOST_ONLY_FIRST_TASK_CREDIT, bool, false, "Only give host credit for one task (whatever they do first)?"), diff --git a/source/sgp_mode/SGPHost.h b/source/sgp_mode/SGPHost.h index 902b54a0..79c52248 100644 --- a/source/sgp_mode/SGPHost.h +++ b/source/sgp_mode/SGPHost.h @@ -50,7 +50,7 @@ class SGPHost : public Host { * object as my_config from superclass, but with the correct subtype. * */ - // emp::Ptr sgp_config; + emp::Ptr sgp_config; // // Function to configure functionality. // void ConfigureDefaults() { @@ -81,8 +81,8 @@ class SGPHost : public Host { ) : Host(_random, _world, _config, _intval, _syms, _repro_syms, _points), hardware(_world, this), - my_world(_world) - // sgp_config(_config) + my_world(_world), + sgp_config(_config) { } /** @@ -100,8 +100,8 @@ class SGPHost : public Host { ) : Host(_random, _world, _config, _intval, _syms, _repro_syms, _points), hardware(_world, this, genome), - my_world(_world) - // sgp_config(_config) + my_world(_world), + sgp_config(_config) { } SGPHost(const SGPHost& host) : @@ -171,11 +171,6 @@ class SGPHost : public Host { */ void SetReproCount(size_t _in) { reproductions = _in; } - void SetLocation(emp::WorldPosition pos) { - hardware.GetCPUState().SetLocation(pos); - Host::SetLocation(pos); - } - void DecPoints(double amt) { points -= amt; @@ -263,7 +258,6 @@ class SGPHost : public Host { if (GetDead()) { return; } - // NOTE - Discuss timing of endosym pre-process signal and host preprocess signal // Currently endosyms go first and then hosts. This is to model endosyms // having opportunity to steal / donate cpu cycles and then host responding @@ -290,7 +284,7 @@ class SGPHost : public Host { } // Endosymbiont gains baseline number of CPU cycles cur_symbiont->GetHardware().GetCPUState().GainCPUCycles( - my_world->GetConfig().CYCLES_PER_UPDATE() + sgp_config->CYCLES_PER_UPDATE() ); my_world->TriggerBeforeEndoSymHostProcessSig( {endosym_i + 1, GetLocation().GetIndex()}, @@ -298,7 +292,7 @@ class SGPHost : public Host { this ); } - my_world->before_host_cpu_exec_sig.Trigger(*this); + my_world->TriggerBeforeHostCPUExec(*this); // Host may have died as a result of this signal. if (GetDead()) { @@ -326,10 +320,10 @@ class SGPHost : public Host { AttemptReproduction(pos); } - my_world->after_host_cpu_step_sig.Trigger(*this); + my_world->TriggerAfterHostCPUStep(*this); // NOTE - Check death here? } - my_world->after_host_cpu_exec_sig.Trigger(*this); + my_world->TriggerAfterHostCPUExec(*this); // Handle any endosymbionts (configurable at setup-time) // NOTE - is there any reason that this might need to be a functor? ProcessEndosymbionts(); @@ -338,7 +332,7 @@ class SGPHost : public Host { return; } GrowOlder(); - my_world->after_host_process_sig.Trigger(*this); + my_world->TriggerAfterHostProcess(*this); } void ProcessEndosymbionts() { @@ -388,7 +382,7 @@ class SGPHost : public Host { * TODO: Perhaps Default mode should have something similar */ void AttemptReproduction(const emp::WorldPosition& pos) { - const double repro_cost = my_world->GetConfig().HOST_REPRO_RES(); + const double repro_cost = sgp_config->HOST_REPRO_RES(); if (GetPoints() >= repro_cost) { // Host pays cost DecPoints(repro_cost); @@ -434,7 +428,7 @@ class SGPHost : public Host { // Is this a host task? if (!task_env.IsHostTask(task_id)) continue; // Not first task - const bool not_first_task = my_world->GetConfig().HOST_ONLY_FIRST_TASK_CREDIT() && cpu_state.GetFirstTaskPerformed().Any() && !cpu_state.GetFirstTaskPerformed().Get(task_id); + const bool not_first_task = sgp_config->HOST_ONLY_FIRST_TASK_CREDIT() && cpu_state.GetFirstTaskPerformed().Any() && !cpu_state.GetFirstTaskPerformed().Get(task_id); if (not_first_task) { continue; } diff --git a/source/sgp_mode/SGPSymbiont.h b/source/sgp_mode/SGPSymbiont.h index 18668c34..0c5738a1 100644 --- a/source/sgp_mode/SGPSymbiont.h +++ b/source/sgp_mode/SGPSymbiont.h @@ -44,7 +44,7 @@ class SGPSymbiont : public Symbiont { * object as my_config from superclass, but with the correct subtype. * */ - // emp::Ptr sgp_config = NULL; + emp::Ptr sgp_config = NULL; public: /** * Constructs a new SGPSymbiont as an ancestor organism, with either a random @@ -60,9 +60,10 @@ class SGPSymbiont : public Symbiont { ) : Symbiont(_random, _world, _config, _intval, _points), hardware(_world, this), - my_world(_world) + my_world(_world), + sgp_config(_config) { - // sgp_config = _config; + } /** @@ -78,10 +79,9 @@ class SGPSymbiont : public Symbiont { ) : Symbiont(_random, _world, _config, _intval, _points), hardware(_world, this, genome), - my_world(_world) - { - // sgp_config = _config; - } + my_world(_world), + sgp_config(_config) + {} SGPSymbiont(const SGPSymbiont& symbiont) : Symbiont(symbiont), @@ -220,7 +220,7 @@ class SGPSymbiont : public Symbiont { if (GetDead()) { return; } - + GetHardware().GetCPUState().SetLocation(pos); if(my_host) my_world->TriggerBeforeEndoSymProcessSig(pos, *this, my_host); //Note: this is different than before_endosym_host_process_sig // Cash in cycles for this update diff --git a/source/sgp_mode/SGPWorld.h b/source/sgp_mode/SGPWorld.h index 5d26a512..20a0372c 100644 --- a/source/sgp_mode/SGPWorld.h +++ b/source/sgp_mode/SGPWorld.h @@ -21,6 +21,7 @@ #include #include +#include // TODO - Document how each base configuration works for SGPWorld // TODO - Comments for every member variable / function / type alias @@ -208,158 +209,11 @@ class SGPWorld : public SymWorld { // Tag used to trigger start module in signalgp programs during run tag_t START_TAG; - // -- Signals to allow custom behavior to be triggered by other classes -- / - // AEV question: getter methods for these? - - // begin_update_sig - Triggers at the beginning of an Update call. - // Triggers before schedule update, before processing any organisms. - // E.g., used for resetting any per-update data tracking. - emp::Signal begin_update_sig; - - // ---- Symbiont birth signals / functors ---- - // before_sym_do_birth_sig - Triggers during SymDoBirth function. - // Triggers after sym offspring is created but before fun_sym_do_birth() is called. - emp::Signal, /* sym_baby_ptr */ - const emp::WorldPosition& /* parent_pos */ - )> before_sym_do_birth_sig; - - // after_sym_do_birth_sig - Triggers during SymDoBirth function. - // Triggers after fun_sym_do_birth() is called. - emp::Signal /* parent_sym */ - )> after_sym_do_birth_sig; - - // fun_sym_do_birth - Configurable functor that handles calling appropriate - // "DoBirth" function depending on whether free-living symbionts are turned on. - fun_sym_do_birth_t fun_sym_do_birth; - - // ---- Host birth signals / functors ---- - // before_host_do_birth_sig - Triggers during HostDoBirth(). - // When this triggers, host offspring has been created (when reproduction queue) - // is processed. Triggers before endosymbionts attempt vertical transmission and - // before DoBirth is called. - emp::Signal before_host_do_birth_sig; - - // after_host_do_birth_sig - Triggers during HostDoBirth(). - // Triggers after endosymbionts attempt vertical transmission and after DoBirth - // is called on the host offspring. - // NOTE - add more parameters to this? We know the parent / offsspring where this is called. - emp::Signal after_host_do_birth_sig; - - // ---- Host process signals / functors ---- - // before_host_cpu_exec_sig - Triggers in ProcessHostAt() - // Triggers before running the host's CPU / after updating host location. - // Host is not guaranteed to still be alive if prior actions attached to this signal - // kill the host. - emp::Signal before_host_cpu_exec_sig; - - // after_host_process_sig - Triggers in ProcessHostAt() - // Triggers at end of ProcessHostAt. There is one final check for death after - // after this triggers in case an attached action kills the host. - emp::Signal after_host_process_sig; - - // after_host_cpu_step_sig - Triggers in ProcessHostAt() - // Triggers after each CPU cycle (potentially multiple times per update) and after - // handling a repro attempt by the host for that CPU cycle. - emp::Signal after_host_cpu_step_sig; - - // after_host_cpu_exec_sig - Triggers in ProcessHostAt() - // Triggers after executing all CPU cycles allotted to host being processed and - // before processing the host's endosymbionts. - emp::Signal after_host_cpu_exec_sig; - // fun_process_endosym_t fun_process_endosym; // NOTE - not used at the moment - - // ---- Free-living symbiont signals / functors ---- - // before_freeliving_sym_process_sig - Triggers in ProcessFreeLivingSymAt() - // Triggers if sym is alive before executing sym's CPU. - emp::Signal before_freeliving_sym_process_sig; - - // after_freeliving_sym_process_sig - Triggers in ProcessFreeLivingSymAt() - // Triggers at end of ProcessFreeLivingSymAt, but before a final check/potential - // DoSymDeath call - emp::Signal after_freeliving_sym_process_sig; - - // after_freeliving_sym_cpu_step_sig - Triggers in ProcessFreeLivingSymAt() - // Triggers after each CPU cycle after handling an instruction-triggered repro attempt. - emp::Signal after_freeliving_sym_cpu_step_sig; - - // after_freeliving_sym_cpu_exec_sig - Triggers in ProcessFreeLivingSymAt() - // Triggers after executing all CPU cycles allotted to sym being processed and - // before SGPSymbiont::Process is called. - emp::Signal after_freeliving_sym_cpu_exec_sig; - - // ---- Endosymbiont process signals / functors ---- - // Happens before this endosymbiont's host is processed - emp::Signal before_endosym_host_process_sig; - - // before_endosym_process_sig - Triggers during ProcessEndoSymbiont() - emp::Signal before_endosym_process_sig; - - // after_endosym_process_sig - Triggers during ProcessEndoSymbiont() - emp::Signal after_endosym_process_sig; - - // after_endosym_cpu_step_sig - Triggers during ProcessEndoSymbiont() - emp::Signal after_endosym_cpu_step_sig; - - // after_endosym_cpu_exec_sig - Triggers during ProcessEndoSymbiont() - emp::Signal after_endosym_cpu_exec_sig; // ---- Environment signals/functors ---- // fun_do_resource_inflow_t fun_do_resource_inflow; - // Called in FindHostForHorizontalTrans(), configured in SetupPopStructure(). - // Returns a target position for symbiont to horizontally transmit into. - // Returns std::nullopt if failed to find suitable target position. - std::function( - size_t, /* Parent's host location id in world (pops[0][id])*/ - emp::Ptr /* Pointer to symbiont parent (producing the sym offspring) */ - )> fun_find_host_for_horizontal_trans; - // External facing helpers for orgnanisms to call //void HostAttemptRepro(const emp::WorldPosition& pos, sgp_host_t& host); @@ -489,6 +343,15 @@ class SGPWorld : public SymWorld { bool /* vertical transmission success */ )> after_sym_vert_transmission_sig; + // Called in FindHostForHorizontalTrans(), configured in SetupPopStructure(). + // Returns a target position for symbiont to horizontally transmit into. + // Returns std::nullopt if failed to find suitable target position. + std::function( + size_t, /* Parent's host location id in world (pops[0][id])*/ + emp::Ptr /* Pointer to symbiont parent (producing the sym offspring) */ + )> fun_find_host_for_horizontal_trans; + + // fun_vert_trans_compatible - Called during HostDoBirth to determine if // a given symbiont can vertically transmit into host offspring. fun_vert_trans_compatible_t fun_vert_trans_compatible; @@ -553,6 +416,9 @@ class SGPWorld : public SymWorld { void SetupStressInteractions(); void SetupHealthInteractions(); void SetupNutrientInteractions(); + + void GenerateDefaultProgram(bool is_host); + void GenerateDefaultTaskEnvironment(); // Clear all world signals void ClearWorldSignals() { @@ -584,6 +450,147 @@ class SGPWorld : public SymWorld { (static_cast(org_ptr.Raw()))->GetHardware().GetCPUState(); } + // begin_update_sig - Triggers at the beginning of an Update call. + // Triggers before schedule update, before processing any organisms. + // E.g., used for resetting any per-update data tracking. + emp::Signal begin_update_sig; + + // ---- Symbiont birth signals / functors ---- + // before_sym_do_birth_sig - Triggers during SymDoBirth function. + // Triggers after sym offspring is created but before fun_sym_do_birth() is called. + emp::Signal, /* sym_baby_ptr */ + const emp::WorldPosition& /* parent_pos */ + )> before_sym_do_birth_sig; + + + // after_sym_do_birth_sig - Triggers during SymDoBirth function. + // Triggers after fun_sym_do_birth() is called. + emp::Signal /* parent_sym */ + )> after_sym_do_birth_sig; + + + // fun_sym_do_birth - Configurable functor that handles calling appropriate + // "DoBirth" function depending on whether free-living symbionts are turned on. + fun_sym_do_birth_t fun_sym_do_birth; + + // ---- Host birth signals / functors ---- + // before_host_do_birth_sig - Triggers during HostDoBirth(). + // When this triggers, host offspring has been created (when reproduction queue) + // is processed. Triggers before endosymbionts attempt vertical transmission and + // before DoBirth is called. + emp::Signal before_host_do_birth_sig; + + + // after_host_do_birth_sig - Triggers during HostDoBirth(). + // Triggers after endosymbionts attempt vertical transmission and after DoBirth + // is called on the host offspring. + // NOTE - add more parameters to this? We know the parent / offsspring where this is called. + emp::Signal after_host_do_birth_sig; + + + // ---- Host process signals / functors ---- + // before_host_cpu_exec_sig - Triggers in ProcessHostAt() + // Triggers before running the host's CPU / after updating host location. + // Host is not guaranteed to still be alive if prior actions attached to this signal + // kill the host. + emp::Signal before_host_cpu_exec_sig; + + // after_host_process_sig - Triggers in ProcessHostAt() + // Triggers at end of ProcessHostAt. There is one final check for death after + // after this triggers in case an attached action kills the host. + emp::Signal after_host_process_sig; + + // after_host_cpu_step_sig - Triggers in ProcessHostAt() + // Triggers after each CPU cycle (potentially multiple times per update) and after + // handling a repro attempt by the host for that CPU cycle. + emp::Signal after_host_cpu_step_sig; + + // after_host_cpu_exec_sig - Triggers in ProcessHostAt() + // Triggers after executing all CPU cycles allotted to host being processed and + // before processing the host's endosymbionts. + emp::Signal after_host_cpu_exec_sig; + // fun_process_endosym_t fun_process_endosym; // NOTE - not used at the moment + + // ---- Free-living symbiont signals / functors ---- + // before_freeliving_sym_process_sig - Triggers in ProcessFreeLivingSymAt() + // Triggers if sym is alive before executing sym's CPU. + emp::Signal before_freeliving_sym_process_sig; + + // after_freeliving_sym_process_sig - Triggers in ProcessFreeLivingSymAt() + // Triggers at end of ProcessFreeLivingSymAt, but before a final check/potential + // DoSymDeath call + emp::Signal after_freeliving_sym_process_sig; + + // after_freeliving_sym_cpu_step_sig - Triggers in ProcessFreeLivingSymAt() + // Triggers after each CPU cycle after handling an instruction-triggered repro attempt. + emp::Signal after_freeliving_sym_cpu_step_sig; + + // after_freeliving_sym_cpu_exec_sig - Triggers in ProcessFreeLivingSymAt() + // Triggers after executing all CPU cycles allotted to sym being processed and + // before SGPSymbiont::Process is called. + emp::Signal after_freeliving_sym_cpu_exec_sig; + + // ---- Endosymbiont process signals / functors ---- + // Happens before this endosymbiont's host is processed + emp::Signal before_endosym_host_process_sig; + + // before_endosym_process_sig - Triggers during ProcessEndoSymbiont() + emp::Signal before_endosym_process_sig; + + // after_endosym_process_sig - Triggers during ProcessEndoSymbiont() + emp::Signal after_endosym_process_sig; + + // after_endosym_cpu_step_sig - Triggers during ProcessEndoSymbiont() + emp::Signal after_endosym_cpu_step_sig; + + // after_endosym_cpu_exec_sig - Triggers during ProcessEndoSymbiont() + emp::Signal after_endosym_cpu_exec_sig; + public: SGPWorld( emp::Random& rnd, @@ -812,6 +819,49 @@ class SGPWorld : public SymWorld { after_endosym_process_sig.Trigger(sym_pos, sym, static_cast(*host)); } + void TriggerBeforeSymDoBirth(emp::Ptr sym_baby_ptr, + const emp::WorldPosition& parent_pos){ + before_sym_do_birth_sig.Trigger(sym_baby_ptr, parent_pos); + } + + void TriggerAfterSymDoBirth(const emp::WorldPosition& sym_baby_pos, + emp::Ptr parent_sym){ + after_sym_do_birth_sig.Trigger(sym_baby_pos, parent_sym); + } + + void TriggerBeforeHostDoBirth(sgp_host_t& host_offspring_ptr, + sgp_host_t& host_parent_ptr, + const emp::WorldPosition& parent_pos){ + before_host_do_birth_sig.Trigger(host_offspring_ptr, host_parent_ptr, parent_pos); + } + + void TriggerAfterHostDoBirth(const emp::WorldPosition& host_offspring_pos){ + after_host_do_birth_sig.Trigger(host_offspring_pos); + } + + void TriggerBeforeHostCPUExec(sgp_host_t& host) { + before_host_cpu_exec_sig.Trigger(host); + } + + void TriggerAfterHostCPUStep(sgp_host_t& host) { + after_host_cpu_step_sig.Trigger(host); + } + + void TriggerAfterHostCPUExec( + sgp_host_t& host + ) { + after_host_cpu_exec_sig.Trigger(host); + } + + void TriggerAfterHostProcess( + sgp_host_t& host + ) { + after_host_process_sig.Trigger(host); + } + + + + const std::unordered_set& GetJumpInstOpcodes() const { return sgp_jump_opcodes; } /** diff --git a/source/sgp_mode/SGPWorldSetup.cc b/source/sgp_mode/SGPWorldSetup.cc index 3fd95371..904be834 100644 --- a/source/sgp_mode/SGPWorldSetup.cc +++ b/source/sgp_mode/SGPWorldSetup.cc @@ -383,10 +383,26 @@ void SGPWorld::SetupHosts(long unsigned int* POP_SIZE) { const size_t init_pop_size = *POP_SIZE; emp_assert(init_pop_size <= scheduler.GetScheduleSize()); + const bool host_prog_file_exists = std::filesystem::exists(sgp_config.HOST_PROGRAM_PATH()); + if (!host_prog_file_exists) { + if(sgp_config["HOST_PROGRAM_PATH"]->GetDefault() == sgp_config["HOST_PROGRAM_PATH"]->GetLiteralValue()){ + std::cout << "Default Host program file does not exist: " << sgp_config.HOST_PROGRAM_PATH() << std::endl; + std::cout << "Generating now... " << std::endl; + GenerateDefaultProgram(true); + std::cout << "Run ./symbulation_sgp again to use new Host program" << std::endl; + std::cout << "Exiting.." << std::endl; + } + else{ + std::cout << "Host program file does not exist: " << sgp_config.HOST_PROGRAM_PATH() << std::endl; + } + + std::exit(EXIT_FAILURE); + } for (size_t i = 0; i < init_pop_size; ++i) { emp::Ptr new_host; sgp_prog_t init_prog( - prog_builder.CreateNandProgram(PROGRAM_LENGTH) + prog_builder.LoadProgramFile(sgp_config.HOST_PROGRAM_PATH()) + //prog_builder.CreateNandProgram(PROGRAM_LENGTH) ); switch (sgp_org_type) { case org_mode_t::DEFAULT: @@ -409,8 +425,23 @@ void SGPWorld::SetupHosts(long unsigned int* POP_SIZE) { // NOTE - what about other Start MOI values? // - these endosymbionts have empty programs? if (sgp_config.START_MOI() == 1) { + const bool sym_prog_file_exists = std::filesystem::exists(sgp_config.SYM_PROGRAM_PATH()); + if (!sym_prog_file_exists) { + if(sgp_config["SYM_PROGRAM_PATH"]->GetDefault() == sgp_config["SYM_PROGRAM_PATH"]->GetLiteralValue()){ + std::cout << "Default Symbiont program file does not exist: " << sgp_config.SYM_PROGRAM_PATH() << std::endl; + std::cout << "Generating now... " << std::endl; + GenerateDefaultProgram(false); + std::cout << "Run ./symbulation_sgp again to use new Symbiont program" << std::endl; + std::cout << "Exiting.." << std::endl; + } + else{ + std::cout << "Symbiont program file does not exist: " << sgp_config.SYM_PROGRAM_PATH() << std::endl; + } + std::exit(EXIT_FAILURE); + } sgp_prog_t sym_prog( - prog_builder.CreateNandProgram(PROGRAM_LENGTH) + prog_builder.LoadProgramFile(sgp_config.SYM_PROGRAM_PATH()) + //prog_builder.CreateNandProgram(PROGRAM_LENGTH) ); emp::Ptr new_sym = emp::NewPtr( random_ptr, @@ -472,6 +503,21 @@ void SGPWorld::SetupSymbionts(long unsigned int* total_syms) { void SGPWorld::SetupTaskEnvironment() { // TODO - configure any world <--> environment interactions that need to be // setup prior to run + const bool env_file_exists = std::filesystem::exists(sgp_config.TASK_ENV_CFG_PATH()); + if (!env_file_exists) { + if(sgp_config["TASK_ENV_CFG_PATH"]->GetDefault() == sgp_config["TASK_ENV_CFG_PATH"]->GetLiteralValue()){ + std::cout << "Default Task Environment file does not exist: " << sgp_config.TASK_ENV_CFG_PATH() << std::endl; + std::cout << "Generating now... " << std::endl; + GenerateDefaultTaskEnvironment(); + std::cout << "Run ./symbulation_sgp again to use new Task Environment" << std::endl; + std::cout << "Exiting.." << std::endl; + } + else{ + std::cout << "Environment file does not exist: " << sgp_config.TASK_ENV_CFG_PATH() << std::endl; + } + + std::exit(EXIT_FAILURE); + } task_env.Setup( sgp_config.TASK_ENV_CFG_PATH(), sgp_config.TASK_IO_BANK_SIZE(), @@ -556,6 +602,61 @@ void SGPWorld::SetupMutator() { // same with endosymbionts / etc } +/** + * Input: Bool, Whether the missing default program is the host or sym program. + * + * Output: None. + * + * Purpose: Creates the default genome and then ends the simulation + */ +void SGPWorld::GenerateDefaultProgram(bool is_host){ + std::string path; + if(is_host){ + path = sgp_config.HOST_PROGRAM_PATH(); + } + else{ + path = sgp_config.SYM_PROGRAM_PATH(); + } + prog_builder.SaveProgramFile(prog_builder.CreateNandProgram(PROGRAM_LENGTH), path); +} + +/** + * Input: None + * + * Output: None + * + * Purpose: Creates the default task environment and then ends the simulation + */ +void SGPWorld::GenerateDefaultTaskEnvironment(){ + std::string path = sgp_config.TASK_ENV_CFG_PATH(); + + std::ofstream envFile(path); + + if (!envFile) { + std::cout << "Error: Could not create new environment file" << std::endl; + std::exit(EXIT_FAILURE); + } + + envFile << R"({ + "shared": { + "tasks": [ + {"name": "NAND", "value": 1, "reward_mode": "add"}, + {"name": "NOT", "value": 1, "reward_mode": "add"}, + {"name": "OR_NOT", "value": 2, "reward_mode": "add"}, + {"name": "AND", "value": 2, "reward_mode": "add"}, + {"name": "OR", "value": 4, "reward_mode": "add"}, + {"name": "AND_NOT", "value": 4, "reward_mode": "add"}, + {"name": "NOR", "value": 8, "reward_mode": "add"}, + {"name": "XOR", "value": 8, "reward_mode": "add"}, + {"name": "EQU", "value": 16, "reward_mode": "add"} + ] + } +})"; + + envFile.close(); + +} + } #endif \ No newline at end of file diff --git a/source/sgp_mode/hardware/CPUState.h b/source/sgp_mode/hardware/CPUState.h index 56cf641d..4d368e42 100644 --- a/source/sgp_mode/hardware/CPUState.h +++ b/source/sgp_mode/hardware/CPUState.h @@ -86,7 +86,6 @@ class CPUState { emp::Ptr organism; // Unowned pointer to organism using this CPU. emp::Ptr world_ptr; // Unowned pointer to the world using this CPU. - emp::WorldPosition location; public: CPUState( @@ -148,7 +147,6 @@ class CPUState { jump_table.clear(); - location = emp::WorldPosition(); } // Reset cpu state, but keep num_tasks the same. @@ -166,9 +164,9 @@ class CPUState { } void SetLocation(const emp::WorldPosition& loc) { - location = loc; + GetOrgPtr()->SetLocation(loc); } - const emp::WorldPosition& GetLocation() const { return location; } + const emp::WorldPosition GetLocation() const { return GetOrg().GetLocation(); } void SetCPUCyclesToExec(size_t num) { cpu_cycles_to_exec = num; @@ -220,8 +218,6 @@ class CPUState { } } - // const emp::WorldPosition& GetLocation() const { return loc; } - void SetOrganism(emp::Ptr org_ptr) { organism = org_ptr; } diff --git a/source/sgp_mode/tasks/LogicTaskEnvironment.h b/source/sgp_mode/tasks/LogicTaskEnvironment.h index d5add786..8992a617 100644 --- a/source/sgp_mode/tasks/LogicTaskEnvironment.h +++ b/source/sgp_mode/tasks/LogicTaskEnvironment.h @@ -181,13 +181,8 @@ void LogicTaskEnvironment::LoadTasks(const std::string& env_filepath) { // Then, tasks can be associated with a particular resource pool. // === Parse environment file === - // Check if given environment file exists. Exit if not. - const bool env_file_exists = std::filesystem::exists(env_filepath); - if (!env_file_exists) { - std::cout << "Environment file does not exist: " << env_filepath << std::endl; - std::exit(EXIT_FAILURE); - } - // If environment file exists, read it. + emp_assert(std::filesystem::exists(env_filepath)); + std::ifstream env_ifstream(env_filepath); nlohmann::json env_json; env_ifstream >> env_json; diff --git a/source/test/sgp_mode_test/NandProgram100.json b/source/test/sgp_mode_test/NandProgram100.json new file mode 100644 index 00000000..88f2aa82 --- /dev/null +++ b/source/test/sgp_mode_test/NandProgram100.json @@ -0,0 +1,1487 @@ +{ + "value0": [ + { + "operation": "Global Anchor", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "1111111111111111111111111111111111111111111111111111111111111111", + "descriptors": [ + { + "key": "summary", + "value": "register a global jump-to destination, maybe terminate" + }, + { + "key": "tag bits", + "value": "1111111111111111111111111111111111111111111111111111111111111111" + }, + { + "key": "tag moniker", + "value": "flawed mayfly" + } + ] + }, + { + "operation": "IO", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + }, + { + "operation": "IO", + "args": { + "value0": 1, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + }, + { + "operation": "IO", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + }, + { + "operation": "Nand", + "args": { + "value0": 0, + "value1": 1, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Nop-0", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [ + { + "key": "summary", + "value": "perform no operation" + } + ] + }, + { + "operation": "Reproduce", + "args": { + "value0": 0, + "value1": 0, + "value2": 0 + }, + "bitstring": "0000000000000000000000000000000000000000000000000000000000000000", + "descriptors": [] + } + ] +} \ No newline at end of file diff --git a/source/test/sgp_mode_test/functional_tests/ProgramBuilder.test.cc b/source/test/sgp_mode_test/functional_tests/ProgramBuilder.test.cc index 86a3efbb..92465207 100644 --- a/source/test/sgp_mode_test/functional_tests/ProgramBuilder.test.cc +++ b/source/test/sgp_mode_test/functional_tests/ProgramBuilder.test.cc @@ -149,6 +149,35 @@ TEST_CASE("ProgramBuilder generates a programs as advertised", "[sgp]") { ); } + WHEN("creating a NAND program from path") { + hw.Reset(); + // Set program of organism to something else + hw.SetProgram( + world.GetProgramBuilder().LoadProgramFile("source/test/sgp_mode_test/NandProgram100.json") + ); + world.AssignNewEnvIO(hw.GetCPUState()); + + // Run organism's hardware for 102 steps + hw.RunCPUStep(102); + auto& output_buffer = hw.GetCPUState().GetOutputBuffer(); + CheckTaskProfile( + world, + hw, + {}, + { "NOT","NAND","OR_NOT","AND","OR","AND_NOT","NOR","XOR","EQU" } + ); + REQUIRE(output_buffer.size() > 0); + sgp_host.ProcessOutputBuffer(); + REQUIRE(output_buffer.size() == 0); + CheckTaskProfile( + world, + hw, + { "NAND" }, + { "NOT", "OR_NOT","AND","OR","AND_NOT","XOR","NOR","EQU" } + ); + } + + WHEN("creating a repro program") { hw.Reset(); // Set program of organism to something else diff --git a/source/test/sgp_mode_test/unit_tests/ProgramBuilder.test.cc b/source/test/sgp_mode_test/unit_tests/ProgramBuilder.test.cc index ff38c0ad..568cc255 100644 --- a/source/test/sgp_mode_test/unit_tests/ProgramBuilder.test.cc +++ b/source/test/sgp_mode_test/unit_tests/ProgramBuilder.test.cc @@ -638,12 +638,17 @@ std::string ReadFileContents(const std::filesystem::path& path) { return oss.str(); } -TEST_CASE("Example program files regenerate identically", "[sgp][sgp-unit]"){ +TEST_CASE("Example program files regenerate identically", "[sgp][sgp-unit][elias]"){ + using tag_t = typename hw_spec_t::tag_t; GIVEN("A program builder"){ const size_t program_len = 100; + sgpl::OpCodeRectifier rectifier; sgpmode::ProgramBuilder builder(rectifier); + tag_t START_TAG; + START_TAG.SetUInt64(0, std::numeric_limits::max()); + builder.SetStartTag(START_TAG); WHEN("NotProgram100.json is regenerated"){ const std::string json_str = builder.MakeJsonString( builder.CreateNotProgram(program_len) diff --git a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc index 79401dca..e9d79577 100644 --- a/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc +++ b/source/test/sgp_mode_test/unit_tests/SGPHost.test.cc @@ -309,4 +309,34 @@ TEST_CASE("Check that hosts and syms can't have negative points", "[sgp][sgp-uni } } } +} + +TEST_CASE("CPUState and SGPHost always have the same location","[sgp]"){ + using world_t = sgpmode::SGPWorld; + using cpu_state_t = sgpmode::CPUState; + using hw_spec_t = sgpmode::SGPHardwareSpec; + using sgp_host_t = sgpmode::SGPHost; + using sgp_sym_t = sgpmode::SGPSymbiont; + + emp::Random random(31); + sgpmode::SymConfigSGP config; + world_t world(random, &config); + auto& prog_builder = world.GetProgramBuilder(); + emp::Ptr host = emp::NewPtr(&random, &world, &config, prog_builder.CreateReproProgram(100)); + + WHEN("Initialized"){ + THEN("Host and CPUState return the same location"){ + REQUIRE(host->GetHardware().GetCPUState().GetLocation().GetIndex() == host->GetLocation().GetIndex()); + } + } + WHEN("Host has location set"){ + host->SetLocation(emp::WorldPosition(1, 2)); + THEN("Symbiont and CPUState return the same location"){ + REQUIRE(host->GetHardware().GetCPUState().GetLocation().GetIndex() == host->GetLocation().GetIndex()); + } + } + WHEN("CPUState has location set"){ + host->GetHardware().GetCPUState().SetLocation(emp::WorldPosition(3, 4)); + REQUIRE(host->GetHardware().GetCPUState().GetLocation().GetIndex() == host->GetLocation().GetIndex()); + } } \ No newline at end of file diff --git a/source/test/sgp_mode_test/unit_tests/SGPSymbiont.test.cc b/source/test/sgp_mode_test/unit_tests/SGPSymbiont.test.cc index 34ec3d3e..ef10e8a8 100644 --- a/source/test/sgp_mode_test/unit_tests/SGPSymbiont.test.cc +++ b/source/test/sgp_mode_test/unit_tests/SGPSymbiont.test.cc @@ -132,3 +132,36 @@ TEST_CASE("Symbiont Process", "[sgp][sgp-unit]") { // } // } // } + +TEST_CASE("CPUState and SGPSymbiont always have the same location","[sgp]"){ + using world_t = sgpmode::SGPWorld; + using cpu_state_t = sgpmode::CPUState; + using hw_spec_t = sgpmode::SGPHardwareSpec; + using sgp_host_t = sgpmode::SGPHost; + using sgp_sym_t = sgpmode::SGPSymbiont; + + emp::Random random(31); + sgpmode::SymConfigSGP config; + world_t world(random, &config); + auto& prog_builder = world.GetProgramBuilder(); + emp::Ptr sym = emp::NewPtr(&random, &world, &config, prog_builder.CreateReproProgram(100)); + + WHEN("Initialized"){ + THEN("Symbiont and CPUState return the same location"){ + REQUIRE(sym->GetHardware().GetCPUState().GetLocation().GetIndex() == sym->GetLocation().GetIndex()); + } + } + + WHEN("Symbiont has location set"){ + sym->SetLocation(emp::WorldPosition(1, 2)); + THEN("Symbiont and CPUState return the same location"){ + REQUIRE(sym->GetHardware().GetCPUState().GetLocation().GetIndex() == sym->GetLocation().GetIndex()); + } + } + WHEN("CPUState has location set"){ + sym->GetHardware().GetCPUState().SetLocation(emp::WorldPosition(3, 4)); + THEN("Symbiont and CPUState return the same location"){ + REQUIRE(sym->GetHardware().GetCPUState().GetLocation().GetIndex() == sym->GetLocation().GetIndex()); + } + } +} \ No newline at end of file