[Mod] Visual Bots [1.2] [vbots]

Post Reply
User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

[Mod] Visual Bots [1.2] [vbots]

by Nigel » Post

Visual Bots
Visually programmable turtle bots for minetest
(c) 2019 Nigel Garnett

Image

Vbots are single block "turtle" style bots, programmable in an entirely visual way.
They came into existence to amuse my 5 year old daughters, and teach them the basics of computer programming, without too much writing.

Instructions available here...

Code: MIT, textures: CC BY-SA 3.0 Unported

Mod dependencies: none

Download v1.2:
vbots_v1.2.zip
(120.13 KiB) Downloaded 335 times
Download v1.1:
vbots1.1_stable.zip
(118.74 KiB) Downloaded 255 times
Download v1.0: vbots1.0_stable.zip
Source: Github
Attachments
vbot screenshot
vbot screenshot
2019-08-09-005554_800x600_scrot.png (400.79 KiB) Viewed 3186 times
Last edited by Nigel on Wed Aug 14, 2019 10:41, edited 6 times in total.

User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [mod] Vbots [1.0] [visual-bots]

by rubenwardy » Post

Please note that "visual-bots" isn't a valid mod name. It looks like the title should be: [Mod] Visual Bots [1.0] [vbots]
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.0] [vbots]

by Nigel » Post

Name fixed. thanks.
My Published Mods: Visual Bots | Symmetool Mirror

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: [Mod] Visual Bots [1.0] [vbots]

by runs » Post

Oh, cool, to learn programming. It remains me the LOGO turtle.

User avatar
Yvanhoe
Member
Posts: 140
Joined: Fri Jul 05, 2019 03:18
Location: Japan

Re: [Mod] Visual Bots [1.0] [vbots]

by Yvanhoe » Post

That's awesome! Thanks for that!

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.0] [vbots]

by Nigel » Post

@runs:
Yeah, i wanted simple LOGO style bots they can control & program themselves.

@Yvanhoe
You are welcome.
My Published Mods: Visual Bots | Symmetool Mirror

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [Mod] Visual Bots [1.0] [vbots]

by Desour » Post

Tested.
I like it!

(There are some little bugs that can be probably fixed easily, like that you can take out the instruction items into your inventory.)

(Some things needed for complex things like conditional jumping (eg. if the node in front is stone, run the horse code) or memory would be useful.)
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.0] [vbots]

by Nigel » Post

Thanks for testing 8-)

I agree. the instruction items are harmless, so I'm not worried about them right now ;-), but on the next cleanup, the whole 'subprogram' inventory needs a rework.

Indeed, a conditional jump is next on the to-do list, as that will make the language 'Turing complete' allowing basically any behavior to be made ;-)

First up however is a code cleanup 8o)
My Published Mods: Visual Bots | Symmetool Mirror

DoyleChris
Member
Posts: 265
Joined: Sat Jul 25, 2015 19:54
In-game: DoyleChris

Re: [Mod] Visual Bots [1.0] [vbots]

by DoyleChris » Post

I will be testing this out on my server with my 7 year old. He plays a game on the table, to guide a person through a maze. This will add some more interaction for my son. Also i will be testing it out heavily to find problems, but first glance it runs good.

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.0] [vbots]

by Nigel » Post

Thanks for testing. BTW I answered the issue you opened on github. more info is needed if these were not the case.
My Published Mods: Visual Bots | Symmetool Mirror

DoyleChris
Member
Posts: 265
Joined: Sat Jul 25, 2015 19:54
In-game: DoyleChris

Re: [Mod] Visual Bots [1.0] [vbots]

by DoyleChris » Post

Maybe a stop button or action and reset

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.0] [vbots]

by Nigel » Post

There is a stop button, as it says in the instructions:
Punch a running vbot with an empty hand to stop the program.
You could help yourself a lot if you read the instructions for the mod.

Instructions are available here.

also you can fully reset by digging the bot & placing another, however I think I'll add a button to remove all the programs, I agree it would be handy. Thanks for the idea.

Have fun ;-)
My Published Mods: Visual Bots | Symmetool Mirror

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.1] [vbots]

by Nigel » Post

There we go, updated to v1.1 with a new button to reset all the current programs to empty. Thanks to DoyleChris for the idea.

Enjoy...
My Published Mods: Visual Bots | Symmetool Mirror

CalebJ
Member
Posts: 407
Joined: Sat Dec 29, 2018 19:21
GitHub: KaylebJay
IRC: KaylebJay
In-game: CalebJ
Location: Tunnelers' Abyss

Re: [Mod] Visual Bots [1.1] [vbots]

by CalebJ » Post

Wow, reminds me of the simplicity of Scratch ;) Great mod!

DoyleChris
Member
Posts: 265
Joined: Sat Jul 25, 2015 19:54
In-game: DoyleChris

Re: [Mod] Visual Bots [1.1] [vbots]

by DoyleChris » Post

I received this error when i went to rename one of the saved files.

Code: Select all

2019-08-13 18:03:22: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'vbots' in callback on_playerReceiveFields(): ...GB/minetest/bin/../mods/visual-bots/formspec_handler.lua:157: attempt to index local 'bot_data' (a nil value)
2019-08-13 18:03:22: ERROR[Main]: stack traceback:
2019-08-13 18:03:22: ERROR[Main]:       ...GB/minetest/bin/../mods/visual-bots/formspec_handler.lua:157: in function <...GB/minetest/bin/../mods/visual-bots/formspec_handler.lua:13>
2019-08-13 18:03:22: ERROR[Main]:       /mnt/700GB/minetest/bin/../builtin/game/register.lua:419: in function </mnt/700GB/minetest/bin/../builtin/game/register.lua:399>
The reset switch works well thank you.
Another idea if possible be able to rename bot.

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.2] [vbots]

by Nigel » Post

I've never seen that error, and can't seem to reproduce it. I can see what the problem is, but am baffled as to how the situation came to be.

Still, I've updated the code in a way which should stop the situation happening.

Enjoy.
My Published Mods: Visual Bots | Symmetool Mirror

neoh4x0r
Member
Posts: 82
Joined: Wed Aug 29, 2018 20:16
GitHub: neoh4x0r

Re: [Mod] Visual Bots [1.2] [vbots]

by neoh4x0r » Post

DoyleChris wrote:I received this error when i went to rename one of the saved files.

Code: Select all

2019-08-13 18:03:22: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'vbots' in callback on_playerReceiveFields(): ...GB/minetest/bin/../mods/visual-bots/formspec_handler.lua:157: attempt to index local 'bot_data' (a nil value)
2019-08-13 18:03:22: ERROR[Main]: stack traceback:
2019-08-13 18:03:22: ERROR[Main]:       ...GB/minetest/bin/../mods/visual-bots/formspec_handler.lua:157: in function <...GB/minetest/bin/../mods/visual-bots/formspec_handler.lua:13>
2019-08-13 18:03:22: ERROR[Main]:       /mnt/700GB/minetest/bin/../builtin/game/register.lua:419: in function </mnt/700GB/minetest/bin/../builtin/game/register.lua:399>
The reset switch works well thank you.
Another idea if possible be able to rename bot.
Nigel wrote:I've never seen that error, and can't seem to reproduce it. I can see what the problem is, but am baffled as to how the situation came to be.

Still, I've updated the code in a way which should stop the situation happening.

Enjoy.
I'm not sure, but it might be due to bot_rekey() setting the bot_key to nil and creating an
inconsistency when register_on_player_receive_fields is called.

EG: when form_parts[2] is used to get the bot_data, was for the formspec updated to reference new_key ?

If the bot_key referenced the old key then it would definitely make bot_data nil, since it does not exist.

It is also possible that bot_key contained no commas which would make form_parts[2] nil, which would result in the same as above -- bot_data is nil.

Also, when acquring bot_data, and it is nil, it might be a good idea to print/log and error that the reference bot_key could not be located.

https://github.com/nyje/visual-bots/blo ... andler.lua

Code: Select all

-------------------------------------
-- generate new key & move data in table
-------------------------------------
local function bot_rekey(bot_key,meta)
    local new_key = vbots.get_key()
    vbots.bot_info[new_key] = vbots.bot_info[bot_key]
    vbots.bot_info[bot_key] = nil
    meta:set_string("key", new_key)
    return new_key
end

line 78: local form_parts = string.split(bot_key,",")
-- updated to this to ensure that bot_key contains a comma before
-- attempting to split, still need to check the length of form_parts
local form_parts = { bot_key }
if string.match(form_parts, ",") then
 form_parts = string.split(bot_key,",")
end

-- no check that form_parts[2] is not nil or an empty string, need to check the length before using it

if form_parts[2] == nil or  form_parts[2] == "" then 
 -- log message
 return
end

if table.getn(form_parts) < 2 then
 -- log message
 return
end
line 156: local bot_data = vbots.bot_info[form_parts[2]]
     line 156.5: if bot_data == nil then print("Could not find bot_key ['" .. bot_key .. "']") return end
line 157: local pos=bot_data.pos

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.2] [vbots]

by Nigel » Post

Thanks for looking into that, but as I stated I already fixed the way the issue could occur.

After a server restart, the bot data does not exist. The key is retrieved from the node metadata when opening a formspec, but I missed a couple of cases.

bot_rekey() does not set bot_key to nil, and bot_key is local to that function anyway (function parameters only have local scope).
bot_rekey() moves the local copy of the bot_info record to the new key, then removes the old bot_info record (if it existed).

As regards form_parts, there is no need to check for "," characters in in the source string.
If the string does not contain a "," then #form_parts ~= 2, this is checked for in each "if" clause below it.

All of this part of the code is going to be refactored in a coming update, since it is a horrible mess, and I need to add some more functionality.

Also table.getn() should not be used in lua 5.1+,(it is depreciated) the length operator "#" should be used (which it is in the code)

The issue of no bot_info record for that particular key when opening the reload/delete formspecs was overcome by explicitly calling bot_restore() when creating the formspecs in init.lua


Anyway thanks for showing an interest and making me think ;-)
My Published Mods: Visual Bots | Symmetool Mirror

tvtd
New member
Posts: 3
Joined: Thu Oct 31, 2019 07:12

Re: [Mod] Visual Bots [1.2] [vbots]

by tvtd » Post

This mod is incredibly cool! I've written several Logo-like games before but this one beats most of them! It would be easy to overwhelm Nigel with suggestions so I will try not to, knowing that time and effort are precious.

First, a bug observation. I'm not sure if this mod is supposed to work in a multi-player situation, but if so, I find that once a second player has saved programs, I can get some funny behavior when loading (like the wrong program recalls). I have not investigated this fully enough to be much help as I will have to re-create a world and start from scratch.

As for suggestions, I'll try to keep it to a minimum.

1. Could we instruct the robot to select a particular kind of block from inventory to place? Maybe follow a "place block" command with the icon of the particular block to be used. That way my miner can return to a loading dock, place a particular kind of treasure on an elevator, then place a mesecon block in a "switch" to close a circuit to activate the elevator, then dig the mesecon block back to inventory.

2. A way for the outside world to affect running of sub-routines would be great. Electricity from a mesecon, something touching one side of the robot, whatever. I want a way to have a solar panel tell a robot to do something once per day. Conditionals that could detect sides individually would be nice if loops were available. Failing that, the ability to launch a sub-routine when a stimulus happens to a side of the robot would be great! If there were dedicated sub-routines for each side of the robot and a way to enable and disable them, then you would have event-driven functionality without adding a lot of new icons/commands. This would also allow off-boarding of some "intelligence" making the robot a very useful extension of another system.

3. I use this as a flying carpet. Can it have a remote?

I'll stop there. Again, great job! My son, who's familiar with other Logo-like systems really took to the 3D thinking this offers.

User avatar
Nigel
Member
Posts: 29
Joined: Fri May 03, 2019 09:08
GitHub: nyje
IRC: Nigel
In-game: Nigel
Location: Corinth, Greece

Re: [Mod] Visual Bots [1.2] [vbots]

by Nigel » Post

Firstly, thanks for the kind words.

This project has been on the back burner for a while, as the code needs a major refactor in order to add any new features ;-)

They are supposed to work in multiplayer, and I thought I had fixed the issues, but indeed there seems to be an issue, and this has led me to be interested in the project again...

I'll have a look at cleaning up the code some more, addressing the bug, and from there, for sure we can add the features you wanted, I particularly want to add some testing operations to make the language turing complete, but I like your ideas too, I never thought of making it respond like that... hmmmmm ;-)

I'll have a look at the code again as soon as I get some time.
My Published Mods: Visual Bots | Symmetool Mirror

User avatar
Visitor247
Member
Posts: 21
Joined: Tue Dec 03, 2019 11:09

Re: [Mod] Visual Bots [1.2] [vbots]

by Visitor247 » Post

Hi Nigel,
Great Mod, just what I need for my next lessons.
I'm not sure what the changes in 1.2 are, but can we use the Mod in Multiplayer (in my case a class with 20 students)?

Suggestions from me:
It would be great if we could save the programs as a file on disk so that students could hand me their programs which I then could load into a different turtle. Otherwise if you hit your turtle to hard, the program is gone.

Also, it would be nice to have a save dialog for naming and not have to rename a program while loading.

A reset button would be nice as well so you can put the turtle back to its start position with the right facing for the program to run.
That way I could go to a student's turtle reset it and let it run to see if it was programmed as instructed.
(I imagine I let the students build a small labyrinth a then let them program the turtle to get through it.)

Or maybe you have ideas how to solve a student teacher relation, where the student has to program the turtle a certain way and the teacher is later, even when the student is no longer online, able to survey the program.

Guido

User avatar
BirgitLachner
Member
Posts: 393
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: [Mod] Visual Bots [1.2] [vbots]

by BirgitLachner » Post

Hey cool ...

I recently saw the mod in a video. Did not realized, that a new Turtle-Bot was born last year. I will need to test it, because I tried an own bot viewtopic.php?f=9&t=15689&start=50

I had some more ideas, to make it possible to improve the turtles to have more abilities.

The ability to programm by dragging is thing, where I had no idea, how to realize that.
https://github.com/BiLachner/TurtleMiner

But some users added a bit of scripting: See https://www.youtube.com/watch?v=3kbbj4HP7lE and https://www.youtube.com/watch?v=34w6UouqqTs

At the moment I don't have any time to continue, but you mod shows, how to add visual progamming.

Birgit

AlienHunter
New member
Posts: 7
Joined: Sun Nov 07, 2021 19:25
GitHub: alienhunter3010
In-game: Alienhunter3010

Re: [Mod] Visual Bots [1.2] [vbots]

by AlienHunter » Post

Hi to all, loving this lad :D but I have an Issue:

It works fine on a local world, but it accept only the first command if I'm connected to my server on a Raspberry Pi: to build a complex program I need to enter and exit from the dialog adding one command at the time.

Is it happening to everyone else?

There is a public server that is using this mod? So I can try it there...

I'm using 5.5.0-dev, compiled from the master branch on github, as client and as server.

[SOLVED] moving the random seed on init phase. Maybe I can submit a pull request?

mattruffoni
New member
Posts: 8
Joined: Wed Jun 09, 2021 13:23
In-game: mattruffoni

Re: [Mod] Visual Bots [1.2] [vbots]

by mattruffoni » Post

Hi, I'm Matteo Ruffoni a teacher from Italy. I installed vbots on the server for my students and now I would write a guide in italian language translating your one. I need to upload the images on wikimedia commons with CC by sa licence, or CC0. Do you think is that possibile?

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests