Creating Minetest Battle Bots using Blockly

Post Reply
User avatar
Neuromancer
Member
Posts: 964
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

Creating Minetest Battle Bots using Blockly

by Neuromancer » Post

I just realized that if we are successful in implementing Blockly for Minetest modding, that this would allow players with little to no programming experience to program battle bots that would be able to make offensive and defensive moves, mine resources, craft tools and weapons, build bunkers and fight battles.

Then we could have battles and competitions on servers to see who could program the most powerful battle bots, or spawn armies of these bots to fight wars, build castles, whatever.
Last edited by Neuromancer on Mon Nov 18, 2013 00:12, edited 1 time in total.

User avatar
hoodedice
Member
Posts: 1374
Joined: Sat Jul 06, 2013 06:33
GitHub: hoodedice
IRC: hoodedice
In-game: hoodedice
Location: world
Contact:

by hoodedice » Post

Neuromancer wrote:I just realized that if we are successful in implementing Blockly for Minetest modding, that this would allow players with little to no programming experience to program battle bots that would be able to make offensive and defensive moves, mine resources, craft tools and weapons, build bunkers and fight battles.

Then we could have battles and competitions on servers to see who could program the most powerful battle bots, or spawn armies of these bots to fight wars, build castles, whatever.
Cue giant server lag because nooby programmers weren't optimizing their code. OR in the heat of battle and pressure from parents like Neuro (joke) they created bots with over 5000 lines of code. Blocks.
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build

like2omg
Member
Posts: 37
Joined: Sat Nov 30, 2013 20:12

by like2omg » Post

hoodedice wrote:Cue giant server lag because nooby programmers weren't optimizing their code. OR in the heat of battle and pressure from parents like Neuro (joke) they created bots with over 5000 lines of code. Blocks.
The way to solve that is by making a custom interpreter so, for example, infinite loops can just error out instead (see Minecraft mod ComputerCraft (shall be called CC from now on)). Telling Lua to execute custom Lua might be hard (I don't know, I'm not a Lua expert... nowhere close) although if set up correctly, allow a certain amount of commands and if it doesn't yield, error out.
That could be accomplished like in CC:

Code: Select all

-- Start a timer that will last n seconds
os.startTimer(n)
-- Wait (non-blocking) for the specific event called "timer"
os.pullEvent("timer")
Another way to accomplish would be to allow only one command per server tick / amount of real time (whichever is larger, or some other factor) per "battle bot" (which still would require a complex setup of a Lua engine)...
If we can have/find C/C++ code to emulate Lua, things should be a bit quicker / more reliable (hopefully).

Notes to consider if implementing it:
  • Keeping track of position in code
  • Keeping track of variable values
  • Handling errors the clean way (sanity checks in "battle bot" lua code to prevent major errors)
.. Sorry if this is going nowhere, as I do know CC is a modification for a Java game (Minecraft) and Java is totally different than a mix of C/C++/Lua. I was just trying to do my best with giving ideas.

P.S. Yes, CC does cause lag on servers in Minecraft which is one of the reasons a lot of servers had that mod banned in (what is now) Tekkit Classic (Minecraft modpack).

HALtheWise
New member
Posts: 1
Joined: Thu Jan 23, 2014 15:43

by HALtheWise » Post

Blockly does have an optional feature that is an "infinite loop counter" that is inserted inside every loop. It is usually used as a hard limit (10,000 loops) before a solution "fails", but it could also be used to throttle the loop to some reasonable speed. Additionally, we could do what CC does, and implement a slight delay with each call to a function. Though anyone writing raw code themselves can, of course, get around these restrictions, they should help with blockly-generated code.

Another possible method is to implement the entire user-supplied code as an onTick(worldState) function that we can simply terminate if it doesn't finish in time.

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

Is anyone now really optimizing mods ?

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

by rubenwardy » Post

Lol.

I do optimize my own, but probably not enough.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
hoodedice
Member
Posts: 1374
Joined: Sat Jul 06, 2013 06:33
GitHub: hoodedice
IRC: hoodedice
In-game: hoodedice
Location: world
Contact:

by hoodedice » Post

aldobr wrote:Is anyone now really optimizing mods ?
They don't, but they should. I might, when I release them
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build

Post Reply

Who is online

Users browsing this forum: Astrobe and 11 guests