Last active
May 29, 2023 20:13
-
-
Save kenwebb/aea1ef77292caf8bbad135501f10206c to your computer and use it in GitHub Desktop.
ChatGPT - Binary Tree 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Mon May 29 2023 16:13:33 GMT-0400 (Eastern Daylight Saving Time)--> | |
<XholonWorkbook> | |
<Notes><![CDATA[ | |
Xholon | |
------ | |
Title: ChatGPT - Binary Tree 1 | |
Description: | |
Url: http://www.primordion.com/Xholon/gwt/ | |
InternalName: aea1ef77292caf8bbad135501f10206c | |
Keywords: | |
My Notes | |
-------- | |
29 May 2023 | |
See my file ~/A001_OpenAI/chatGPT24.txt | |
I asked a series of questions, starting with these two: | |
Consider a binary tree consisting of a finite number of discrete nodes, and a clock that produces a timestep at each discrete interval of time. | |
Initially the binary tree has exactly one node with id 0. At each timestep each node randomly creates a new node, deletes a node, moves to some adjacent part of the tree. So the structure of the tree evolves over time. How can I describe all of this using mathematics? | |
]]></Notes> | |
<_-.XholonClass> | |
<PhysicalSystem/> | |
<NodeSet/> | |
<Node/> | |
</_-.XholonClass> | |
<xholonClassDetails> | |
</xholonClassDetails> | |
<PhysicalSystem> | |
<!-- Node Set: | |
Denote the set of all nodes at time step t as N(t). | |
Each node can be represented by its unique identifier (ID). | |
Initially, at time step t=0, N(0) contains only node 0. | |
--> | |
<NodeSet> | |
<Node ID="0"/> | |
<!-- console.log(temp0.name() + "|" + temp0.ID); node_51|0 --> | |
</NodeSet> | |
</PhysicalSystem> | |
<NodeSetbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[ | |
var me, testing, uid=0, beh = { | |
postConfigure: function() { | |
testing = Math.floor(Math.random() * 10); | |
me = this.cnode.parent(); | |
console.log(me); | |
me.parent().append(this.cnode.remove()); | |
console.log(me.numChildren()); | |
uid++; | |
}, | |
act: function() { | |
me.println(this.toString()); | |
console.log(me.first().numChildren()); | |
//me.first().visit(me); | |
me.first().visit(this.cnode); | |
}, | |
toString: function() { | |
return "testing:" + testing + " " + me.numChildren() + " " + this.P_create(0); | |
}, | |
visit: function(visitor) { | |
me.println("visited by " + visitor + " " + visitor.ID); | |
if (Math.random() < this.P_create(0)) { | |
this.createNode(visitor); | |
return false; | |
} | |
if (Math.random() < this.P_delete(0) && visitor.first()) { | |
this.deleteNode(visitor.first()); | |
return false; | |
} | |
if (Math.random() < this.P_move(0)) { | |
this.moveNode(visitor); | |
return false; | |
} | |
return true; | |
}, | |
P_create: t => 0.05, | |
P_delete: t => 0.02, | |
P_move: t => 0.03, | |
createNode: node => node.append(`<Node ID="${uid++}"/>`), | |
deleteNode: node => node.remove(), | |
moveNode: node => { | |
const root = me.first(); | |
//me.println(`move root ${root.name()}`); | |
var pnode = node; | |
var nnode = pnode.next(); | |
while (!nnode && (pnode != root)) { | |
pnode = pnode.parent(); | |
nnode = pnode.next(); | |
} | |
//me.println(`move stuff ${node.name()} ${nnode} ${pnode}`); | |
if (nnode) { | |
me.println(`moving ${node.name()} to ${nnode.name()}.`); | |
node.color("red"); | |
nnode.append(node.remove()); | |
} | |
} | |
} | |
//# sourceURL=NodeSetbehavior.js | |
]]></NodeSetbehavior> | |
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml, | |
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg"> | |
<g> | |
<title>NodeSet</title> | |
<rect id="PhysicalSystem/NodeSet" fill="#98FB98" height="50" width="50" x="25" y="0"/> | |
<g> | |
<title>Height</title> | |
<rect id="PhysicalSystem/NodeSet/Node" fill="#6AB06A" height="50" width="10" x="80" y="0"/> | |
</g> | |
</g> | |
</svg> | |
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient> | |
</XholonWorkbook> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment