Any idea what affects the execution of ABMs?

Post Reply
whoanders
New member
Posts: 2
Joined: Wed Feb 08, 2023 22:07
GitHub: algorev
In-game: whoanders

Any idea what affects the execution of ABMs?

by whoanders » Post

I've discovered minetest recently. To try out mod creation, I decided to create the project any good troll would make. I'm not going to explain it right away, this video should make the concept clear:

https://www.youtube.com/watch?v=qF_yTnX_s94

That's it: a self-replicating block. I made it by creating a block and applying the following ABM to it:

Code: Select all

minetest.register_abm({ nodenames = {"expanding_orb:orb"}, interval = 5, chance = 5,
			action = function(pos)
					for x = -1,1,1 do
						for y = 0,1,1 do
							for z = -1,1,1 do
								tempPos = vector.new(pos.x, pos.y, pos.z) -- Vector copy
								tempPos.x = tempPos.x + x
								tempPos.y = tempPos.y + y
								tempPos.z = tempPos.z + z
								minetest.add_node(tempPos, {name="expanding_orb:orb"})
							end
						end
					end
				 end
			})
As you can see by this piece of code, the block should multiply in all directions equally. However, as you can see in the video, blocks tend to appear way more in a certain direction. Where does this bias come from?

I haven't put this in the "problems" section as I don't really see this as a problem, but I'm curious about specifically why this happens.

User avatar
Desour
Member
Posts: 1473
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: Any idea what affects the execution of ABMs?

by Desour » Post

Some of the newly added nodes are considered for abms in the current abm application. This is also why it grows so fast. The directional bias comes from the traversal order. See here: <https://github.com/minetest/minetest/bl ... t.cpp#L873>

P.S.: Make your variable local.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

whoanders
New member
Posts: 2
Joined: Wed Feb 08, 2023 22:07
GitHub: algorev
In-game: whoanders

Re: Any idea what affects the execution of ABMs?

by whoanders » Post

That makes sense. Thanks for the explanation and source code link!

P.S.: Oops, you're right about the variable. I've not gotten fully used to this quirk of lua yet.

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests