Factorio as a training ground for AI agents

This is the place to request new mods or give ideas about what could be done.
Post Reply
jlam
Manual Inserter
Manual Inserter
Posts: 1
Joined: Thu Sep 28, 2023 8:06 pm
Contact:

Factorio as a training ground for AI agents

Post by jlam »

Inspired by this paper on AI generative agents learning in Minecraft - https://arxiv.org/pdf/2305.16291.pdf, I started exploring whether it would be possible to do the same thing in Factorio.

The interesting thing about the paper is that the AI constructs plans for learning a task, e.g., "Craft 1 crafting table" or "Smelt 3 iron ore". Once it has learned a task, it remembers it as a skill. Skills are Javascript programs generated by the model that interact with the game API. Skills are recalled by computing embeddings against the model-generated docstrings for the skills.

Here's an example of a function generated by the model to do some manual mining:

Code: Select all

async function mineTenCobbledDeepslateBelowY0(bot) {
    // Equip the iron pickaxe
    const ironPickaxe = bot.inventory.findInventoryItem(mcData.
        itemsByName[" iron_pickaxe "].id);
    await bot.equip(ironPickaxe, " hand ");
    // Find cobbled_deepslate blocks below Y=0
    const cobbledDeepslateBlocks = await exploreUntil(bot, new Vec3(1,
        -1, 1), 60, () = > {
            const cobbledDeepslate = bot.findBlock({
                matching: mcData.blocksByName[" cobbled_deepslate "].id,
                maxDistance: 32,
                position: pos = > pos.y < 0
            }) ;
            return cobbledDeepslate ;
        });
    // Mine 10 cobbled_deepslate blocks
    await mineBlock(bot, " cobbled_deepslate ", 10);
    bot.chat("10 cobbled_deepslate mined below Y=0.");
}
While I have played a bit of Factorio and launched a rocket, I don't have much experience with the API. It seems like there's some unholy combination of LUA scripting and sending commands via RCON that might accomplish something similar? Was wondering if someone who knows this well could help point me in the right direction?

Thx!
-John

EustaceCS
Inserter
Inserter
Posts: 42
Joined: Tue Dec 15, 2020 5:41 am
Contact:

Re: Factorio as a training ground for AI agents

Post by EustaceCS »

So you'd like to implement a sort of "golem mode" showcased in some old classic rogue-likes? You know, where you generate the character then let AI play it instead of player.

While I have no experience with Factorio modding API yet, I assume that Factorio <-> AI "bridge mod" boils down to letting AI:
- move character
- interact (including creation and efficiency evaluation) blueprints
- interact with entities around (which in turn should be separated into interactions with different entity classes, like selecting recipes in production buildings, or driving car/tank/etc)
- be at least somewhat aware of its surroundings
- be able to understand and interact with tech tree
- logistics optimization
- PLAN AND MAINTAIN FACTORY DEFENCES

Which is not rocket science per se. It just needs some very careful premeditation and documentation studying.

To be completely honest, most of these tasks don't require AI generative learning at all. Just some creative scripting will suffice.
Most positions from my list are must-have for Strategy genre AI already (and were there for ages). It just needs slight adaptation to non-Strategy controls scheme (or cheesing with personal roboport infinite range :) ).

Post Reply

Return to “Ideas and Requests For Mods”