Possible Implementation of a Monkey Tree
I’m just putting this out there so that you guys can tell me how buggy it is before we actually attempt to add it to the ruleset.
The Monkey Tree is an endless tree made of Nodes, each of which can be termed a Root, a Junction, or a Leaf. The Nodes may each contain zero or more Monkeys. No Monkey may occupy more than one Node of the tree at a time.
There is one Node of the Monkey Tree which is known as the Root. The Root is always a part of the Monkey Tree. If the Root contains no Monkeys, the tree is Empty, and the Root contains no Branches. If the Root contains any Monkeys, than it has two Branches; a Left Branch and a Right Branch. Each of these Branches contains one Node.
All other Nodes in the tree are either referred to as Junctions or Leaves. Every Junction contains two Branches; a Left Branch, and a Right Branch. Each of these Branches contains one Node.
If a Leaf has any Monkeys in it, it becomes a Junction. If a Junction contains no Monkeys, and neither of the Nodes in its Branches are Junctions, it becomes a Leaf, and the Nodes that were formerly in its Branches are no longer considered to be part of the tree. If a Junction or the Root contains no Monkeys, but one or both of the Nodes in its Branches are Junctions, than any Monkey may move either the Monkey in the Node in the Junction’s Left Branch or the Monkey in the Node in the Junction’s Right Branch into the Junction.
If a Junction or the Root ever contains more than one Monkey, than any Monkey may either move the Monkey whose name occurs earlier in the alphabet to the Node in the Junction or Root’s Left Branch, or move the Monkey whose name occurs later in the alphabet to the Junction or Root’s Right Branch.
Whenever a Monkey’s status is changed to “In the Tree”, they move into the Root of the tree.
This tree just sorts Monkeys by name at the moment, but it could be modified to sort them by Fritos, or bananas, or dance moves, or whatever. I don’t know if Clucky intended this be the kind of tree than could sort things, or the kind of tree that Monkeys can climb around at will, though, so all that could be modified. If you want to make it some kind of dynamically resizable non-binary tree, that could get pretty complicated, though… Anyway, this actually works opposite to the way programming trees do because all Monkeys are added at the root and rest of the tree just reshuffles itself. I didn’t think it would be worth it to write complicated instructions on how to navigate to the right Leaf when we can just make a simple instruction about how to deal with each overcrowded Junction.
Also, if we wind up representing it in a tree-like structure in the wiki, I’d personally prefer it have the root at the bottom. Unlike programmers and syntacticians, Monkeys know that trees grow UP.
ETA: Perhaps we should initialize the Branch-Nodes of newly created Leaf-to-Junctions to Leaves? I don’t think it really matters, since Junctions with no Monkeys in them become Leaves anyway. We’d also have to make sure multiple Monkeys can’t leave the tree before someone gets to updating it, because if the Monkeys in a Junction and its two Branch-Nodes all left at one, than parts of the tree would go permanently missing.
Son-of-a-ETA: I don’t seem to be able to log into or make changes to the wiki. I know my browser is saving cookies. Help?