ComputerCraft Turtles that self-replicate by mining their own resources and crafting the necessary components for new turtles to be created.
After several turtles have been created, it starts another system which acts as a complex 'hive' mind that has leader-driven behavior. This will give turtles specific jobs, such as farming trees, mining resources, crafting materials, smelting resources, etc.
This only takes effect after a threshold of turtles have been replicated.
For this implementation of the system, I have python handle the majority of the calculations, behaviors and procedures of the turtles.
For the turtles, I make them simply connect to the python webserver using websockets to pull the turtle's next job, and I keep state persistence inside the turtle for when they are chunk unloaded and loaded, as the turtle's virtual machine is reloaded, and parse the action then return the results.
The following high-level diagram shows this complete turtle-perspective process of it connecting to the python server.
Here is a perspective of the server-side when the turtle connects to the python websocket:

For the python backend, there is many pieces to the puzzle, so here is quick list of components:
-
CORE COMPONENTS:
- Websocket Wrapper
- Behavior Tree System
- Recipe Resolver
- Asynchronous Operations
-
EXTRA COMPONENTS:
- 3D World Visualizer
- Fully Serializable
And here is a version of the turtle behavior tree diagram for when the turtles are first starting off:

The HIVE behavior tree has not been implemented yet and will be in the future once this base system is complete and the turtles have the capacity to replicate.
...
...
- Have any version of
python 3installed. - Run
pip install -r requirements.txt
- Install
ComputerCraftorComputerCraft:Tweaked; any version is supported that haswebsockets.
- View the installation section if you have not yet.
- Run the following script;
python -> __init__.py
-
In your
Minecraft World Folder, allow websocket connections to your host in theWorld Folder -> serverconfig -> computercraft-server.tomlfile. -
In your turtle, place the following items inside the turtle inventory:
Optionally you can also add any of these additional items to speed up the turtle process:
The final item, the chunk controller, allows the turtle to keep the chunk the turtle is in loaded, and is highly recommended if its available and you are able to craft it.
-
Pick one of the following setup instructions depending on your circumstances:
Singleplayer (World Folder):
i. Copy
turtle -> main -> startup.luafrom this repository to yourturtle folder. You can find the turtle folder in theminecraft world folder -> computercraft -> computer -> [TURTLE_ID]folder. If you need to find your turtle id, open the target turtle and runid.ii. Reboot the turtle with
reboot.SinglePlayer & Multiplayer (Pastebin):
i. Upload
turtle -> main -> startup.luafrom this repository to pastebin.ii. In the target turtle, use
pastebin [URL_HERE] startup.lua, replacing[URL_HERE]with the pastebin url.iii. Reboot the turtle with
reboot.Singleplayer & Multiplayer (Manual):
i. Open the
turtle -> main -> startup.luafile in this repository.ii. In the target turtle, type
edit startup.lua.iii. Copy each line from the repository
startup.luaindividually into the computercraft editor.iv. Press
CTRL/COMMANDandSAVEusing the arrow keys and enter.v. Press
CTRL/COMMANDandEXITusing the arrow keys and enter.vi. Reboot the turtle with
reboot.
- [✔️] Connect to python websocket
- [✔️] Preset Actions
- [✔️] Parse Actions
- [✔️] Websocket Server
- [✔️] Parse Incoming Server Requests
- [✔️] Turtle State Persistence Data
- [✔️] Behavior Tree Framework
- [🚧] Save Turtle Current Behavior Tree & Cache Values (State Persistence)
- [🚧] Turtle Behavior Trees
- [🚧] Initializer Tree
- [❌] Main Loop Tree
- [❌] Low Fuel Resolver Tree
- [❌] Mine Resource Tree
- [❌] Dig Tunnel Tree
- [❌] Mine Ore Vein Tree
- [❌] Craft Resource Tree
- [❌] Farm Sapling Tree
- [❌] Farm Sugar Cane
- [❌] Procreate Tree
- [❌] Stranded Behavior Tree
- [❌] Help Stranded Behavior Tree
- [❌] 3D World Viewer
- [❌] 3D World Pathfinding
- [❌] Manual Turtle Controller
- [❌] HIVE System when turtle count reaches >10 turtles?
✔️❌🚧
When testing you can utilize the following command to view and set the fuel to a specific value.
/data modify block [X] [Y] [Z] "Fuel" set value 0/data get block [X] [Y] [Z]
99% of the code was done by me, @SPOOKEXE.
I used this particular resource to solve the turtle replication which is linked below; namely in the genesis function.
Video: https://www.youtube.com/watch?v=MXYZufNQtdQ
Code: https://pastebin.com/YtvRxY9j
Another video resource I used as a 'goal' for the project was to visualize what the turtles see in a 3D space:
Video: https://www.youtube.com/watch?v=pwKRbsDbxqc
Apart from the first reference for code, I did all the code from the ground up.
https://www.computercraft.info/forums2/index.php?/topic/24574-optimization-and-micro-optimization/




