theFox6 / working_villages

A mod for minetest that adds villagers performing work
https://content.minetest.net/packages/theFox/working_villages/
MIT License
13 stars 10 forks source link

mine: going deep down for ores #24

Open scrain777 opened 3 years ago

scrain777 commented 3 years ago

Create a miner who travels deep underground to search for ores. The challenge here will be that, naively, the miner will not be active underground unless the player goes along.

scrain777 commented 3 years ago

Proposed design: Two modes of operation:

Challenge: we will need to do something to load unloaded areas, but a voxel manipulator in a coroutine is probably only safe to use until the next yield, so will need some care around getting blocks loaded and making the changes, Perhaps try to load a block a little before it is needed and be willing to wait if it is not ready on time.

Include some randomness: tunneling, rough stairs, ladders straight down if there are ladders in inventory. Ability to craft torches, stone pickaxes. Other tools need to come by trading/gifting.

I'm debating how much attention to safety. Certainly players sometimes are careless and fall, drown or die in lava.

We might want a well-defined generic API for simulated mobs, so that there can be simulated interactions in the depths. I am especially thinking about goblins, monsters, etc.

lmaddox commented 10 months ago

"The challenge here will be that, naively, the miner will not be active underground unless the player goes along."

That's not really a challenge. My mayor bot will keep her block loaded. It's quick and dirty, though. I need to add logic to detect whether she's left her current block, and allow it to be unloaded. We also need to add all sorts of logic for actually tracking villages, and then I can try to get her to wander around the village without leaving it.

The challenge with the miner is that he likes to burrow to the depths of Hades, and creating a dangerous pit that he can't get out of.

Screenshot_2023-12-02_18_19_51 Screenshot_2023-12-02_18_19_53


At this level, jobs should be fairly simple: the bot should really just do one task. I want to build more complex logic (ie job-changing) logic on top of this. For example, hostile mobs should go about their business (in the working_villages sense of the word) unless in the presence of a player or otherwise provoked.

In my setup, I've got three "miners" with the same logic.


re: tunneling, rough stairs, ladders straight down if there are ladders in inventory.

Have you tried the builder? Both the builder and the current miner would have to function more smoothly before combining their functionalities.


re: Ability to craft torches, stone pickaxes. Other tools need to come by trading/gifting.

I've added a craftsman based on the crafting_bench mod, so the groundwork is there. For better realism, the :dig() method should be refactored to properly use the wielded item... And then everybody is going to need logic for cycling their worn out tools and returning them to their chests, so that a courier (not yet implemented) can transport them to the blacksmith (not yet implemented) who will use his anvil (not yet implemented) to repair them. And then we've gotta do #4, so the villager tell you how grateful he is that the town thief recovered from another player his great grandfather's high-level pickaxe that had some spell (not yet implemented) cast on it by the town wizard who discovered the magick formula after many months of harrowing attempts, because in today's economy it would take a few generations to save enough capital to replace it... and for that matter, there's going to need to be some lineage-tracking logic, which I'm currently working on for my respawning redo.

My dye mixer bot is a predecessor to the craftsman. She tracks the dependencies for her recipes, hinting at the complexity that would be required to write a more generic craftsman, especially if we want to craft the correct numbers of doors, windows, bricks, chests, etc., for, e.g., the builder to complete a task. I think the easiest solution is to use the same craftsman AI with different recipes, to make a carpenter, mason, etc., and then some down stream craftsmen to make things like doors, windows, gadgets, etc. Then there would need to be some sort of middle management AI to decide how much of any given resource should be distributed to a particular job title.


I think simulating mob interactions is a heavy feature that belongs in a separate mod. Goblins, monsters, etc., definitely should be separate from this mod. I do intend to create some hostile mobs built on this mod once I get some combat strategies implemented here for e.g., the guard.

lmaddox commented 10 months ago

By inverting the search of the bot's surroundings, we can prevent the burrowing behavior, creating a proper quarry.

        --for j = mod_y - searching_range.y, searching_range.y do
        for j = searching_range.y, mod_y - searching_range.y, -1 do
                check_plane(j)
                if ret.pos ~= nil then
                        break
                end
        end

Screenshot_2023-12-02_23_02_09

Screenshot_2023-12-02_23_23_58