Additions to enable an AI team mate
Posted: Wed Jun 04, 2025 5:16 am
I'm developing a mod which will make it possible for users to add an AI team mate (e.g. ChatGPT, Claude, open source model) to a multiplayer game through RCON (Factorio version 1.1.110). The idea is not to provide an AI which can use all the advanced features in the game, instead it will have limited capabilities but would in theory be able to get to launching a rocket.
I want the AI to adhere to the rules of the game like a player. This is almost possible but the character (LuaEntity) lacks a crucial function which is the can_place_entity. I have tried to use LuaSurface.can_place_entity and make some approximations of build reach, but it isn't working as I would like. Furthermore, the LuaSurface.can_place_entity doesn't seem to do any check on e.g. whether there are resources on the tiles when drills are placed.
I see two possible solutions to this:
I want the AI to adhere to the rules of the game like a player. This is almost possible but the character (LuaEntity) lacks a crucial function which is the can_place_entity. I have tried to use LuaSurface.can_place_entity and make some approximations of build reach, but it isn't working as I would like. Furthermore, the LuaSurface.can_place_entity doesn't seem to do any check on e.g. whether there are resources on the tiles when drills are placed.
I see two possible solutions to this:
- Add can_place_entity to LuaEntity. I assume LuaEntity already have the required variables, e.g. build_distance and character_build_distance_bonus which is inherited from LuaControl.
- Add LuaEntity to LuaSurface.can_place_entity so it take position, build_distance, and character_build_distance_bonus of the character into account.