Factorio as a training ground for AI agents
Posted: Thu Sep 28, 2023 8:18 pm
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:
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
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.");
}
Thx!
-John