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.