<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.minetest.org/index.php?action=history&amp;feed=atom&amp;title=Mods%2Fbasic_robot%2FTurtle-Specs</id>
	<title>Mods/basic robot/Turtle-Specs - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.minetest.org/index.php?action=history&amp;feed=atom&amp;title=Mods%2Fbasic_robot%2FTurtle-Specs"/>
	<link rel="alternate" type="text/html" href="https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;action=history"/>
	<updated>2026-04-24T13:24:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.4</generator>
	<entry>
		<id>https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;diff=12420&amp;oldid=prev</id>
		<title>&gt;ROllerozxa: /* Instruction-set */</title>
		<link rel="alternate" type="text/html" href="https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;diff=12420&amp;oldid=prev"/>
		<updated>2023-02-14T15:28:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Instruction-set&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:28, 14 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>&gt;ROllerozxa</name></author>
	</entry>
	<entry>
		<id>https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;diff=8655&amp;oldid=prev</id>
		<title>&gt;ROllerozxa: /* Instruction-set */</title>
		<link rel="alternate" type="text/html" href="https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;diff=8655&amp;oldid=prev"/>
		<updated>2023-02-14T15:28:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Instruction-set&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:28, 14 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>&gt;ROllerozxa</name></author>
	</entry>
	<entry>
		<id>https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;diff=4890&amp;oldid=prev</id>
		<title>&gt;ROllerozxa: /* Instruction-set */</title>
		<link rel="alternate" type="text/html" href="https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;diff=4890&amp;oldid=prev"/>
		<updated>2023-02-14T15:28:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Instruction-set&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:28, 14 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>&gt;ROllerozxa</name></author>
	</entry>
	<entry>
		<id>https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;diff=1125&amp;oldid=prev</id>
		<title>&gt;ROllerozxa: /* Instruction-set */</title>
		<link rel="alternate" type="text/html" href="https://wiki.minetest.org/index.php?title=Mods/basic_robot/Turtle-Specs&amp;diff=1125&amp;oldid=prev"/>
		<updated>2023-02-14T15:28:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Instruction-set&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Design of a mini-language / minimal instruction-set for a turtlebot==&lt;br /&gt;
based on basic_robots.&lt;br /&gt;
&lt;br /&gt;
The goal is to teach programming to children,&lt;br /&gt;
using turtle-like programmable robots in minetest.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have turtleminer, with ambitious plans, but still in early development.&lt;br /&gt;
: One big item on that todo-list is a visual code-editor, like blockly or scratch.&lt;br /&gt;
&lt;br /&gt;
We have basic-robots, that are working, really powerful, and can do almost everything.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They are programmable in lua, using an in-game texteditor.&lt;br /&gt;
&lt;br /&gt;
basic-robots should be 'more than good enough' to teach programming in general,&amp;lt;br /&amp;gt;&lt;br /&gt;
but (for kids) the presentation may need some tweaks.&lt;br /&gt;
&lt;br /&gt;
It would be nice to have something like [https://wiki.education.minecraft.net/wiki/Programming_with_ComputerCraftEdu ComputerCraftEdu] &amp;lt;br /&amp;gt;&lt;br /&gt;
with a visual-editor like blockly or scratch for minetest, &amp;lt;br /&amp;gt;&lt;br /&gt;
but implementing that would be a lot of work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Maybe we can come up with smaller, simpler 'programming language'&amp;lt;br /&amp;gt;&lt;br /&gt;
that is more easy to incorporate into the basic-robot&amp;lt;br /&amp;gt;&lt;br /&gt;
that is still useful for an introduction to programming.&lt;br /&gt;
&lt;br /&gt;
===Concept of Turtle-commands===&lt;br /&gt;
Turtles use commands like&lt;br /&gt;
move-forward, move-up, turn-right, dig-forward.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These commands can be represented in different ways, &amp;lt;br /&amp;gt;&lt;br /&gt;
eg. as text, code, numbers, symbols, graphics/icons, etc..&lt;br /&gt;
&lt;br /&gt;
Graphic symbols look nice, but a system &lt;br /&gt;
like blockly or scratch would need a lot of them&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
For a limited number of simple actions this is easy,&amp;lt;br /&amp;gt;&lt;br /&gt;
but gets much more complicated if you want to express variables, &amp;lt;br /&amp;gt;&lt;br /&gt;
calculations, control-structures (if-then-else, for-loops) etc.) &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is a point where it becomes simpler to just write code, eg. for lua, in  a texteditor.&lt;br /&gt;
&lt;br /&gt;
===Turtle-Programs===&lt;br /&gt;
Some examples of existing programs that use basic_robots with turtle-commands:&lt;br /&gt;
* [[Mods/basic_robot#Build4_-_House1|Build4 - House1]] - build a house / small hut.&lt;br /&gt;
* [[Mods/basic_robot#Build5_-_another_housebuilder|Build5 - another housebuilder]] - builds a bigger house&lt;br /&gt;
* [[Mods/basic_robot#Mining103_-_tunnel_2x1|Mining103 - tunnel 2x1]] - this is a small &amp;amp; pretty basic turtle-program, that does not stop.&lt;br /&gt;
* [[Server/TechWelt/RobotWorld#Robot_.2318_-_Demolition|Demolition-Turtle]] - it clears the construction-site for robot #17, by digging away the old building.&lt;br /&gt;
&lt;br /&gt;
Note1: all of these programs have a different instruction-set,&amp;lt;br /&amp;gt;&lt;br /&gt;
and no 'advanced features', like variables, calculation, or conditional execution.&lt;br /&gt;
&lt;br /&gt;
But I remember that rnd once made such an advanced turtle...&lt;br /&gt;
&lt;br /&gt;
Note2: all of the above example-program have the instructions of their turtle-scipt hardcoded.&amp;lt;br /&amp;gt;&lt;br /&gt;
But it would be possible to change that script on the fly, eg. from a book, with a remote-control,&amp;lt;br /&amp;gt;&lt;br /&gt;
by chat or via mail from another robot.&lt;br /&gt;
&lt;br /&gt;
===Idea===&lt;br /&gt;
To minimize the work,&lt;br /&gt;
we design a mini-language, a minimal instruction-set for a turtlebot,&amp;lt;br /&amp;gt;&lt;br /&gt;
that still introduces some basic concepts of programming.&lt;br /&gt;
&lt;br /&gt;
I want to keep the number of instructions down (say 10-20),&amp;lt;br /&amp;gt;&lt;br /&gt;
as well as avoiding composite and variable-length instructions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the basics have been learned, move straight to 'real' coding,&lt;br /&gt;
with lua and texteditor.&lt;br /&gt;
&lt;br /&gt;
===Requirements===&lt;br /&gt;
* what kind of programs do we want to 'write' with that language ?&lt;br /&gt;
: as in, what instructions, how many steps/statements in a program&lt;br /&gt;
* Other required features (as in variables / fuel, input/output, flowcontrol***...) ?&lt;br /&gt;
* (usecase-examples please: task, environment/terrain, program that solves the task)&lt;br /&gt;
* When do we want/need it to be usable ?&lt;br /&gt;
&lt;br /&gt;
For example, I would like to use those robots to do simple tasks such as&lt;br /&gt;
&lt;br /&gt;
====Simple tasks====&lt;br /&gt;
* move the robot around&lt;br /&gt;
: need instructions: move-forward, move-up, move-down, turn-right, turn-left&lt;br /&gt;
::optional:  move-backward, move-right, move-left&lt;br /&gt;
** press a button, activate = open/close a door&lt;br /&gt;
: more instructions: activate-forward&lt;br /&gt;
:: maybe other direcions too&lt;br /&gt;
&lt;br /&gt;
* dig a straight tunnel, size 1x2  (width 1, heigth 2)&lt;br /&gt;
: more instructions: dig-forward&lt;br /&gt;
* dig bigger tunnels, eg. 1x3, 2x2, 3x3&lt;br /&gt;
: more instructions: dig-up, dig-down&lt;br /&gt;
&lt;br /&gt;
* dig stairs up, dig stairs down&lt;br /&gt;
::nice-to-have, but optional: dig-forward-down and dig-forward-up&lt;br /&gt;
* dig a room, eg. 5x5&lt;br /&gt;
&lt;br /&gt;
* stop after x operations&lt;br /&gt;
: needs a counter (a variable), and operations for setting, counting up/down, checking&lt;br /&gt;
: or some kind of 'fuel' that is used up by each operation&lt;br /&gt;
:: that means counting, checking and stopping is done internally&lt;br /&gt;
&lt;br /&gt;
* moving, and react to obstacles (eg. turn when hitting a wall)&lt;br /&gt;
: check for success, conditional execution / jump / exceptions ...&lt;br /&gt;
: might also need block-start / block-end, or labels / markers&lt;br /&gt;
&lt;br /&gt;
Also, it would be nice to have the instructions of several of those 'programs'&lt;br /&gt;
available at the same time.&amp;lt;br /&amp;gt;&lt;br /&gt;
Eg. ability to select different starting-points within a program,&amp;lt;br /&amp;gt;&lt;br /&gt;
or several remote-controls with different programs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====More complicated tasks====&lt;br /&gt;
&lt;br /&gt;
* build a wall&lt;br /&gt;
: needs an inventory for at least 1 type of material&lt;br /&gt;
: needs instructions: build-forward&lt;br /&gt;
: maybe build-backwards, or switch building on/off (for building a 'trail')&lt;br /&gt;
:: like pen-up / pen-down of a logo-turtle&lt;br /&gt;
: optional:  build-up, build-down&lt;br /&gt;
* build stairs up&lt;br /&gt;
* build stairs down&lt;br /&gt;
* build a bridge&lt;br /&gt;
:  basic-robots can only move one space above ground, &lt;br /&gt;
:  so moving to the position for building a block might be a problem&lt;br /&gt;
: maybe needs instructions:  build-forward-down, build-forward-up&lt;br /&gt;
* build a house&lt;br /&gt;
: needs bigger inventory (different materials for floor, walls etc.), &lt;br /&gt;
: and a command to select&lt;br /&gt;
* look for ore&lt;br /&gt;
: needs an instruction for looking at nodes&lt;br /&gt;
: and then do what ?&lt;br /&gt;
:: output a message ...&lt;br /&gt;
* plant &amp;amp; harvest wheat, flowers, trees&lt;br /&gt;
* goal-seeking/homing: use find_nodes() to find an item, eg. a flower&lt;br /&gt;
: this needs 2 real numbers (current- and old value), and a compare-instruction for them&lt;br /&gt;
&lt;br /&gt;
These might be already too complicated for our 'simple' design.&lt;br /&gt;
&lt;br /&gt;
More ideas:&lt;br /&gt;
* Subroutines&lt;br /&gt;
&lt;br /&gt;
===TurtleBot using inventory as code-editor===&lt;br /&gt;
&lt;br /&gt;
For example, it might be fairly easy to implement the 'turtle-instructions' &lt;br /&gt;
move-Forward,Backward,Up,Down,turn-Left,turn-Right, Dig-forward, Activate-forward&lt;br /&gt;
(that makes a 'palette' of 8 instructions**, to fill the hotbar)&lt;br /&gt;
with programs of upto 30 steps, using the inventory of the robot&lt;br /&gt;
(That leaves 2 inventory-slots free for digging stone and ore).&lt;br /&gt;
&lt;br /&gt;
Simple, as in 1 block = 1 instruction - but it means no i/o, no flowcontrol, no vars, no extras.&lt;br /&gt;
&lt;br /&gt;
(**) The exact set of instruction can be discussed/modified somewhat:&lt;br /&gt;
Eg. we could do without turn-Right (just do 3* turn-Left instead),&lt;br /&gt;
or without move-Backward (do right-right-forward-right-right instead).&lt;br /&gt;
Also, we might want to add a check-instruction (eg. 'if ok then...'),&lt;br /&gt;
and perhaps one or more types of marker (start-, stop-marker).&lt;br /&gt;
The robot consuming 'fuel' would be much like having a stop-marker.&lt;br /&gt;
&lt;br /&gt;
(***) even without instructions for flowcontrol, at least we need to define the behaviour&lt;br /&gt;
* when encountering an empty slot / an invalid instruction (such as dirt, stone etc.)&lt;br /&gt;
* when reaching the last inventory-slot&lt;br /&gt;
* when an instruction fails (eg. moving against a wall, diggging air, ...)&lt;br /&gt;
Possible behaviour: &lt;br /&gt;
* indicate success/error (eg. with message, label, sound-effect...)&lt;br /&gt;
* ignore / treat as success / treat as failure&lt;br /&gt;
* stop program &lt;br /&gt;
* continue with next instruction&lt;br /&gt;
* continue with first instruction&lt;br /&gt;
If we add markers to our instructionset, we get some more options, &lt;br /&gt;
eg. 'continue at next start-marker'.&lt;br /&gt;
&lt;br /&gt;
For that, we 'just' need some blocks that represent those instructions/actions.&lt;br /&gt;
Without making nice new graphics, we could use the existing keyboard-blocks for that.&lt;br /&gt;
(see chars.png in the texture-directory of basic_robots)&lt;br /&gt;
&lt;br /&gt;
Give the kids a chest full of such blocks, and let them place &lt;br /&gt;
these blocks into the robots inventory, as a turtle-script,&lt;br /&gt;
and we can think of a way to start the robot so that&lt;br /&gt;
it would interpret the contents of its inventory as a script.&lt;br /&gt;
(Eg. a special start-button, a special id, a special new command, &lt;br /&gt;
look at the inventory for fuel or a start-marker...)&lt;br /&gt;
&lt;br /&gt;
Do you have some suitable graphics to use as textures for such blocks ?&lt;br /&gt;
&lt;br /&gt;
As an alternative idea: using a special remotecontrol&lt;br /&gt;
as the visual-editor for the turtle-script (but that would need &lt;br /&gt;
much more programming, formspec-design, rc-design, etc.).&lt;br /&gt;
&lt;br /&gt;
A 'turtlebot' that works pretty much like that&lt;br /&gt;
(but with its program represented as a text-script)&lt;br /&gt;
is already on TechWelt - see the [[Server/TechWelt/RobotWorld#Robot_.2318_-_Demolition|Robot_#18]]&lt;br /&gt;
&lt;br /&gt;
==Turtle-Commands==&lt;br /&gt;
===Instruction-set===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Letter !! Description !! Code&lt;br /&gt;
|-&lt;br /&gt;
| Arrow right || move-Forward || ok=move.forward()&lt;br /&gt;
|-&lt;br /&gt;
| f&lt;br /&gt;
|-&lt;br /&gt;
| Arrow up   || move-Up&lt;br /&gt;
|-&lt;br /&gt;
| u&lt;br /&gt;
|-&lt;br /&gt;
| Arrow down || move-Down&lt;br /&gt;
|-&lt;br /&gt;
| d&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| l || move-Left  (optional)&lt;br /&gt;
|-&lt;br /&gt;
| r || move-Right (optional)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| &amp;lt; || turn-Left  || turn.left()&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || turn-Right || turn.right()&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| +/- || activate-Forward || ok=activate.forward(1)&lt;br /&gt;
|-&lt;br /&gt;
| a&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| - || dig-Forward || ok=dig.forward()&lt;br /&gt;
|-&lt;br /&gt;
| - ||&lt;br /&gt;
|-&lt;br /&gt;
| Triangle-up    || dig-Up&lt;br /&gt;
|-&lt;br /&gt;
| ~&lt;br /&gt;
|-&lt;br /&gt;
| Triangle-down  || dig-Down&lt;br /&gt;
|-&lt;br /&gt;
| v&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 1 || select slot 1 || mat=check_inventory.self(...,1); mat=...&lt;br /&gt;
|-&lt;br /&gt;
| 2 || select slot 2&lt;br /&gt;
|-&lt;br /&gt;
| 3 || select slot 3&lt;br /&gt;
|-&lt;br /&gt;
|.. ||  || .. etc. ..&lt;br /&gt;
|-&lt;br /&gt;
| 7 || select slot 7 || mat=&amp;quot;air&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 8 || select slot 8 || mat=&amp;quot;farming:wheat_8&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| + || build-Forward || ok=place.forward(mat)&lt;br /&gt;
|-&lt;br /&gt;
| ^ || build-Up&lt;br /&gt;
|-&lt;br /&gt;
| . || build-Down&lt;br /&gt;
|-&lt;br /&gt;
| _ || build-Forward_Down (optional)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp; || build-Backward on/off&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| 0 (Green) || marker-Start / marker-next&lt;br /&gt;
|-&lt;br /&gt;
| 0 ||&lt;br /&gt;
|-&lt;br /&gt;
| 9 (Red) || marker-Stop&lt;br /&gt;
|-&lt;br /&gt;
| 9 ||&lt;br /&gt;
|-&lt;br /&gt;
| p (Yellow) || marker-Pause&lt;br /&gt;
|-&lt;br /&gt;
|  p  || pause / pickup&lt;br /&gt;
|-&lt;br /&gt;
| .!. || pause / pickup&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| ? || check || if ok then continue-with-next-marker&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| n || look for node  || s=read_node.forward()&lt;br /&gt;
|-&lt;br /&gt;
| t || look for text  || s=read_text.forward(); ok=...&lt;br /&gt;
|-&lt;br /&gt;
| ! || output string || say(s)&lt;br /&gt;
|-&lt;br /&gt;
| = || compare string || if s~=mat then continue-with-next-marker&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| # || (reserved) counter&lt;br /&gt;
|-&lt;br /&gt;
| , || (reserved)&lt;br /&gt;
|-&lt;br /&gt;
| : || (reserved) define label&lt;br /&gt;
|-&lt;br /&gt;
| ; || (reserved) marker-next&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| ~~ || (reserved) compare string2 ??&lt;br /&gt;
|-&lt;br /&gt;
| $ || (reserved) compare real&lt;br /&gt;
|-&lt;br /&gt;
| % || (reserved) counter#2 / random&lt;br /&gt;
|-&lt;br /&gt;
| ° || (reserved) look / find_nodes()&lt;br /&gt;
|-&lt;br /&gt;
| @ || (reserved) reset&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| A || (reserved) Subroutines&lt;br /&gt;
|-&lt;br /&gt;
|.. ||  || .. etc. ..&lt;br /&gt;
|-&lt;br /&gt;
| Z || (reserved)&lt;br /&gt;
|-&lt;br /&gt;
| ( || block-Start / Subroutine-Start / :&lt;br /&gt;
|-&lt;br /&gt;
| ) || block-End / Subroutine-End / ;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See also [[Mods:Alphabet_Blocks#basic_robots|Alphabeth-blocks]]&lt;br /&gt;
&lt;br /&gt;
===Rules===&lt;br /&gt;
====Variant1====&lt;br /&gt;
=====Basics=====&lt;br /&gt;
* There is a set of available instructions ('turtle-commands'), see above.&lt;br /&gt;
* There is a script with a sequence of turtle-commands&lt;br /&gt;
** This script can be represented as a string, or by items in the inventory&lt;br /&gt;
* Each turtle-command is represented by one character.&lt;br /&gt;
: eg. 'f' stands for 'move-Forward'&lt;br /&gt;
* If the script-string is empty, the inventory is used as the source for the script,&lt;br /&gt;
*where the item in each slot represent one turtle-command (or building-materialsm etc.)&lt;br /&gt;
: eg. the block 'arrow-right' means 'move-Forward' - same as 'f' when expressed as string.&lt;br /&gt;
&lt;br /&gt;
* There is a 'pause' variable. While true, execution of the script stops.&lt;br /&gt;
* At the start, pause is set to false.&lt;br /&gt;
: This can be changed with a remotecontrol&lt;br /&gt;
&lt;br /&gt;
* There is a variable 'mat', that contains the name of the current building-material.&lt;br /&gt;
* At the start, mat is set to an empty string.&lt;br /&gt;
: maybe start with 'dirt', or contents of slot 1 ?&lt;br /&gt;
* mat can be set with the instructions 1,2, ... 8 to the name of the material in slots 1 .. 8.&lt;br /&gt;
: the item-count of the material is removed&lt;br /&gt;
: Some slots might be reserved for fixed strings, such as &amp;quot;farming:wheat_8&amp;quot; or &amp;quot;air&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note: this might allow some tricks, eg. building with instruction-blocks / selfmodifying code&lt;br /&gt;
: I'm not sure if/why we should restrict this &lt;br /&gt;
::(eg. start script at position 9 would waste 1/4 script-length)&lt;br /&gt;
&lt;br /&gt;
* There is a variable 's', that is used as a temp. string, eg. for read_node().&lt;br /&gt;
* At the start, s is set to an empty string.&lt;br /&gt;
: maybe set it to the name of the robot, or the version-number, &lt;br /&gt;
: or some status, eg. &amp;quot;robot1, fuel=99&amp;quot; ?&lt;br /&gt;
&lt;br /&gt;
* There is an instruction-pointer 'ip' that keeps track of the current instruction&lt;br /&gt;
: i.e. the instruction-pointer starts at position 1.&lt;br /&gt;
* Every script starts at the begin.&lt;br /&gt;
* Every second, one instruction is executed&lt;br /&gt;
: maybe only count actions like moving, digging, building ?&lt;br /&gt;
* and the instruction-pointer advances one step&lt;br /&gt;
&lt;br /&gt;
* If the ip reaches the end of the script, it continues at the start.&lt;br /&gt;
: This repeats until fuel runs out, or an end-instruction is reached.&lt;br /&gt;
&lt;br /&gt;
* Invalid instructions are ignored&lt;br /&gt;
: such as blanks / empty slots, fuel, building-materials etc.&lt;br /&gt;
* The turtle-interpreter scans forward until a valid instruction is found,&lt;br /&gt;
* or the same position is reached again&lt;br /&gt;
: eg. if the script is complete garbage, or empty, etc.&lt;br /&gt;
: ? errormessage / failure-sound ??&lt;br /&gt;
&lt;br /&gt;
* ? instruction for pickup() -- p is already used for pause&lt;br /&gt;
: also what range -- maybe first pickup(4), second pickup(8) ?&lt;br /&gt;
&lt;br /&gt;
=====Fuel=====&lt;br /&gt;
* A Turtle needs 'fuel' to run, &lt;br /&gt;
: eg. leaves (coal would be too valuable - think of mining coal with a coal-burning turtle :)&lt;br /&gt;
:: maybe different types of fuel, eg. leaves for moving, wood or sticks for digging&lt;br /&gt;
: maybe create a new fuel-item, with stacklimit &amp;gt; 99&lt;br /&gt;
* Each step consumes 1 unit of fuel&lt;br /&gt;
: this stops endless loops, and allows precise stopping of the turtle&lt;br /&gt;
: maybe only have 'actions' (move,dig,build) consume fuel, not 'steps'&lt;br /&gt;
:: so internal processing would be free (look/read_node, check, output...)&lt;br /&gt;
* Check for fuel is done before/after ...&lt;br /&gt;
* If fuel runs out, the turtle goes into pause-mode&lt;br /&gt;
: so the player can refill, and unpause with a remote-control&lt;br /&gt;
* maybe require that fuel is put into a certain slot, eg. the last slot ?&lt;br /&gt;
: How to represent fuel when using a script from a string ?&lt;br /&gt;
&lt;br /&gt;
=====Conditionals=====&lt;br /&gt;
* There is a global 'ok' variable that keeps track of the result of each operation, eg.&lt;br /&gt;
 ok=move.forward()&lt;br /&gt;
: Some instructions cannot fail, e.g. turning.&lt;br /&gt;
* The check-instruction tests this variable, and can skip forward to the next marker. &lt;br /&gt;
: Eg. this lua-code:&lt;br /&gt;
 ok=move.forward()&lt;br /&gt;
 if not ok then turn.left() end&lt;br /&gt;
: could be expressed as turtle-instructions&lt;br /&gt;
 f?&amp;lt;0&lt;br /&gt;
:or, using instruction-blocks in the inventory:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| [[File:026_(basic_robot).png | Arrow right]] || [[File:063_(basic_robot).png | ?]] || [[File:060_(basic_robot).png | &amp;lt;]] || [[File:robot_button_green_(basic_robot).png| green]]&lt;br /&gt;
|}&lt;br /&gt;
:: where 0 is the next (green) marker, and '&amp;lt;' is executed when move-Forward failed&lt;br /&gt;
&lt;br /&gt;
=====Strings=====&lt;br /&gt;
* The instructions &amp;quot;n&amp;quot; does  s=read_node.forward()&lt;br /&gt;
* The instructions &amp;quot;t&amp;quot; does  s=read_text.forward(); ok=...&lt;br /&gt;
: and also sets 'ok' if some text was found&lt;br /&gt;
: so we can at least identify objects with text (sign, chest, door, furnace...) even without string-compare&lt;br /&gt;
* The instruction &amp;quot;=&amp;quot; compares s with mat, and (on mismatch) can skip forward to the next marker. &lt;br /&gt;
Eg. this little harvester&lt;br /&gt;
 if read_node.forward() == &amp;quot;farming:wheat_8&amp;quot; then dig.forward() end&lt;br /&gt;
 if read_node.forward() == &amp;quot;air&amp;quot;             then place.forward(&amp;quot;farming:seed_wheat&amp;quot;) end&lt;br /&gt;
 move.forward()&lt;br /&gt;
Could be expressed as&lt;br /&gt;
 8n=-0 7n=1+0 f&lt;br /&gt;
:or, as instruction-blocks in the inventory:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| [[File:056_(basic_robot).png | 8]] [[File:110_(basic_robot).png | n]] || [[File:061_(basic_robot).png | =]] || [[File:016_(basic_robot).png | -]] ||  [[File:robot_button_green_(basic_robot).png| green]] ||  [[File:055_(basic_robot).png | 7]] || [[File:110_(basic_robot).png | n]] ||  [[File:061_(basic_robot).png | =]] || [[File:049_(basic_robot).png | 1]]  || [[File:043_(basic_robot).png | +]] || [[File:robot_button_green_(basic_robot).png| green]] || [[File:026_(basic_robot).png | Arrow right]] &lt;br /&gt;
|}&lt;br /&gt;
where slot 8 has &amp;quot;farming:wheat_8&amp;quot;, slot 7 has &amp;quot;air&amp;quot;, slot 1 has &amp;quot;farming:wheat&amp;quot;, and 0 is a (green) marker.&lt;br /&gt;
: slot 1 needs to be setup by the user, slot 7 &amp;amp; 8 are fixed strings built into the turtle-interpreter.&lt;br /&gt;
&lt;br /&gt;
Note: in this harvester-example, we cannot check for soil, because we have no turtle-instructions for 'read_node.down()' or 'read_node.forward_down()'&lt;br /&gt;
: Also, 'farming:soil' would need an additional special string &lt;br /&gt;
&lt;br /&gt;
* ? store / recall strings ?&lt;br /&gt;
* ? random ?&lt;br /&gt;
&lt;br /&gt;
=====Variables=====&lt;br /&gt;
It would be nice to have variables and arithmetic, but with a small instruction-set, &amp;lt;br /&amp;gt;&lt;br /&gt;
and very little room (&amp;lt;30) for scripts, it seems not practical.&lt;br /&gt;
&lt;br /&gt;
Eg. it would need instructions to set a value, add, substract, check, specify which var,&amp;lt;br /&amp;gt;&lt;br /&gt;
and represent values.&lt;br /&gt;
&lt;br /&gt;
A simpler type of variable are flags and counters.&lt;br /&gt;
* flag (aka boolean) - true and false (such as our internal 'ok'-variable)&lt;br /&gt;
* counter with a specific max-value. Only needs an instruction 'decrement&amp;amp;test-for-zero'.&lt;br /&gt;
: after reaching 0, the counter is restored to its max-value.&lt;br /&gt;
:: with a max-value of 1, a counter works just like a flag&lt;br /&gt;
* to reset it, just repeat reading, until it reaches zero&lt;br /&gt;
&lt;br /&gt;
======Counter======&lt;br /&gt;
The turtle only gets two counters (using the instructions # and %), &amp;lt;br /&amp;gt;&lt;br /&gt;
the max-value is specified by their stackcount in the inventory.&lt;br /&gt;
: That means the max-value must be 1..99&lt;br /&gt;
&lt;br /&gt;
To represent this when using a script from a string,&amp;lt;br /&amp;gt;&lt;br /&gt;
we can extend the script-string, eg. append &amp;quot;;#=5 %=3 fuel=99&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* The instruction &amp;quot;#&amp;quot; decrements the current value of counter1 , and sets the ok-value:&lt;br /&gt;
** ok=true:  success means the value of the counter was &amp;gt; 0, anc could be decremented&lt;br /&gt;
** ok=fail:  value was = 0, and is now set to its max-value again&lt;br /&gt;
* The instruction &amp;quot;%&amp;quot; works likewise on counter2&lt;br /&gt;
&lt;br /&gt;
Such counters are also useful to keep trace of some state-of-processing.&lt;br /&gt;
&lt;br /&gt;
======Real======&lt;br /&gt;
There is a specific usage for real numbers I would like to include with turtles: &amp;lt;br /&amp;gt;&lt;br /&gt;
finding the distance to something via find_nodes(), compare old &amp;amp; new distance-value, &amp;lt;br /&amp;gt;&lt;br /&gt;
with the goal of moving closer to it.&lt;br /&gt;
:Eg. finding flowers on a plain of grass, without visiting each square.&lt;br /&gt;
&lt;br /&gt;
That would need a special instruction like 'compare &amp;amp; store-when-less',&amp;lt;br /&amp;gt;&lt;br /&gt;
and a way to clear the old value, for the next search.&lt;br /&gt;
:Maybe reset when find_nodes() returns nil, meaning 'no such node in range' ?&lt;br /&gt;
&lt;br /&gt;
=====Subroutines=====&lt;br /&gt;
This is optional, but really nice-to-have:&lt;br /&gt;
* Uppercase letters are reserved as names for subroutines&lt;br /&gt;
* To define a subroutines:&lt;br /&gt;
 A(-~f)&lt;br /&gt;
: dig-Forward, dig-Up, move-Forward&lt;br /&gt;
* To call a subroutines:&lt;br /&gt;
 A&lt;br /&gt;
: If an uppercase letter is followed by '(', the body of the subroutine followes, ended by ')'.&lt;br /&gt;
: Otherwise, the interpreter tries to find &amp;amp; execute that subroutine&lt;br /&gt;
* If not found, the program stops&lt;br /&gt;
: ? errormessage ?&lt;br /&gt;
* The call-stack is only 1 level deep, so calls from a subroutine, and recursion are not allowed (yet).&lt;br /&gt;
&lt;br /&gt;
* If a '(' is encountered outside of a subroutine-definition, the interpreter ignores all following instructions upto the next ')'&lt;br /&gt;
: So, (..) also serves as a block-comment.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
===Links===&lt;br /&gt;
&lt;br /&gt;
Forum:&lt;br /&gt;
* [https://forum.minetest.net/viewtopic.php?f=9&amp;amp;t=15689 TurtleMiner ... programmable turtles in Minetest]&lt;br /&gt;
* basic_robot [https://forum.minetest.net/viewtopic.php?f=9&amp;amp;t=15850 forum] [[Mods/basic robot|wiki]]&lt;br /&gt;
&lt;br /&gt;
Resources:&lt;br /&gt;
* https://developers.google.com/blockly&lt;br /&gt;
** http://blockly-lua.appspot.com/static/apps/code/index.html&lt;br /&gt;
* https://scratch.mit.edu/developers&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.education.minecraft.net/wiki/Programming_with_ComputerCraftEdu Introduction to ComputerCraftEdu] - another approach to 'teaching programming to kids'&lt;br /&gt;
* [https://www.robomindacademy.com/go/robomind/help RoboMind Academy] - another system for teaching programming / &amp;quot;Computational thinking&amp;quot; using robots&lt;/div&gt;</summary>
		<author><name>&gt;ROllerozxa</name></author>
	</entry>
</feed>