IA and FACTORIO

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
User avatar
gmy77
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sun Jan 07, 2024 12:17 pm
Contact:

IA and FACTORIO

Post by gmy77 »

I thought that a game with so much to do, invent... using logic to complete tasks... Factorio could be defined as one of those games, where there is only one limit, the imagination of the user. But, I thought, why not add features that implement the use of an IA for certain tasks. I thought it would be interesting to play, in the true sense of the word, with machines that are commanded and programmed and then guided by an AI? I don't know if this idea seems original to you... I don't think so, but I thought it would be remarkably interesting, there could be... crazy implications. :o

I hope I haven't offended anyone... I understand that the imagination and personal creation of everyone takes precedence, I didn't want to create any kind of problem like this. But I really believe it could become an interesting (experiment) in the end.

MrSmoothieHuman
Inserter
Inserter
Posts: 21
Joined: Sat Aug 05, 2023 1:20 am
Contact:

Re: IA and FACTORIO

Post by MrSmoothieHuman »

technically there is "AI" you can do in-game, it just takes crazy amounts of thinking circuit logic (*cough Nialus's self-building base *cough*), but iirc, its not that simple to have external programs work with factorio. There are a couple mods that do add entities that can ""think"" for themselves, like AAI's vehicles and things.

My knowledge on this is limited, but my main takeaway here is that while it *could* be possible, it wouldn't be very easy and i cant personally think of any useful applications. However, there is definitely ways it could be used - just cant think of any myself :lol:
coder? i hardly know her!

Qon
Smart Inserter
Smart Inserter
Posts: 2118
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: IA and FACTORIO

Post by Qon »

I'm close to publishing my "combinassembly"-language which looks like an assembly language and is assembled to combinators. With this my next goal is probably to complete my self building factory, which will kind of be a limited AI. A lot more so than any previous attempts at least since it needs to be able to handle everything which others ignored (resource acquisition, killing natives, power, calculation of what recipes to produce more of, configuration of and some design of blueprints, multiple tasks handled concurrently etc).
After that I'm curious about doing some ML on combinators, maybe with ANNs with backpropagation if there's any reasonable tasks to do live learning and execution on that benefit from it.

User avatar
SteelWolf300
Inserter
Inserter
Posts: 30
Joined: Sat Apr 09, 2016 11:21 am
Contact:

Re: IA and FACTORIO

Post by SteelWolf300 »

Qon wrote:
Wed Jan 17, 2024 5:24 pm
I'm close to publishing my "combinassembly"-language which looks like an assembly language and is assembled to combinators.
Maybe you have already decided on a syntax, but I'm putting it anyway. There is this Cnide project (website) that defines a nice syntax for circuit networks. The syntax could have some improvement (especially with the changes coming in 2.0, as per FFF#384). I've based on that syntax in a project of mine where I implemented the semantic of combinators in a symbolic way, for verification and synthesis of circuit networks (spoiler it is super slow to synthesize, I could verify that this whitelist filtering contraption is indeed compliant to the spec, but I couldn't learn it from scratch).

Anyway I think that it would be beneficial for the community to define some syntax so that anyone could use it in their projects, and hopefully get some interoperability out of it. Would you (or any one else) be interested in participating in defining such a syntax? This might need a post on its own, sorry for being off topic.

Qon
Smart Inserter
Smart Inserter
Posts: 2118
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: IA and FACTORIO

Post by Qon »

SteelWolf300 wrote:
Wed Jan 17, 2024 7:16 pm
Maybe you have already decided on a syntax, but I'm putting it anyway. There is this Cnide project (website) that defines a nice syntax for circuit networks.
Yes, I have a syntax.
Combinassembly (I just published it now!) is not a general HDL though. Its purpose is different, it creates hardware programs with combinators that execute instructions sequentially (or, it is structurally preventing instructions from having effects all at once). But it is meant to be able to do any general purpose computation, as quickly as sequential execution allows, with full access to all Factorio combinator features (so can use any signals, all at once and signals like [each]).

Cnide looks neat, but kind of seems unrelated to Factorio except for theming. The website runs simulated networks, but doesn't have any blueprint output so you can't actually use it inside Factorio.
I was considering making a language similar to Cnide. I guess I don't have to now that it already exists...
SteelWolf300 wrote:
Wed Jan 17, 2024 7:16 pm
Anyway I think that it would be beneficial for the community to define some syntax so that anyone could use it in their projects, and hopefully get some interoperability out of it. Would you (or any one else) be interested in participating in defining such a syntax? This might need a post on its own, sorry for being off topic.
Feel free to use Combinassembly in your project (Though I will make breaking changes in the future). The macro system is flexible enough that most operations and features are really just macros.
The macros and code in the live demo needs to be extended further and cleaned up, but anyone that learns it can do that for themselves if they really want to. But as I've said the syntax is not meant as a HDL to describe any kind of circuit. It is good as a compilation target for a high level language like C though.

Cnide syntax seems good enough at a first glance, why not use that? Any language will need updating once v2.0 drops anyways. If there is no blueprint generator for it yet one could be written.

But yeah make a separate thread for language projects and I'll discuss more details about Combinassembly, Cnide and defining a syntax there.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2752
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: IA and FACTORIO

Post by mmmPI »

MrSmoothieHuman wrote:
Wed Jan 17, 2024 4:09 pm
My knowledge on this is limited, but my main takeaway here is that while it *could* be possible, it wouldn't be very easy and i cant personally think of any useful applications. However, there is definitely ways it could be used - just cant think of any myself :lol:
Someone with more knowledge than me built an "AI" that can play 4-in-a-row in factorio, the map is available on the forum , the creator was kind enough to give some explanations and links to useful ressources to share knowledge :)

It is not the part of the AI that learn how to play the game, but it is the part that already "know" how to play the game. You can play against it like you could play chess on an app, and really it is only you playing against the combinator you just pasted, and they will win ! Worse than losing a game of pac-man :)

There would be other simpler "AI" that exist that wouldn't use neural network, like with AAI vehicule, you can program vehicule behavior with circuits, similar to how self building factory can use the recursive blueprint mod, those are algorithm more than "AI" maybe, but really they all are :)
Qon wrote:
Thu Jan 18, 2024 12:00 am
Combinassembly (I just published it now!) is not a general HDL though. Its purpose is different, it creates hardware programs with combinators that execute instructions sequentially (or, it is structurally preventing instructions from having effects all at once). But it is meant to be able to do any general purpose computation, as quickly as sequential execution allows, with full access to all Factorio combinator features (so can use any signals, all at once and signals like [each]).
But yeah make a separate thread for language projects and I'll discuss more details about Combinassembly, Cnide and defining a syntax there.
Took me roughly 30 minutes to find how to make the example blueprint, most of it after i had clicked the "trying it live" from "read me", not understanding i had to click the green button, instead of reading at the code and wondering what kind of madness and how it would be related to factorio. I might be a bit slow or not having the necessary to knowledge to understand, but when i finally got the blueprint imported in factorio i didn't know what i was looking at, though it looked pretty cool when loading.

When looking back at the website and playing with the tab "blueprint" it made a little more sense what just happened, it seemed the easier tab to start the investigation on what seem otherwise related to magic, and i found where is the 987 number on the circuit, it's at 2 different location ,the upper most decider combinator being the most obvious one but it is also present further down in the array ,and for some reason there is only one lamp lit at a location that seem arbitrary.

I tried with 25 instead of 16, read around 75K, was impressed. I don't dare to touch anything else :). I can understand it calculated the 25th fibonacci number, and also the 16th using a blueprint that is the exact same footprint, so i suppose it loaded a bit more time for the 25th but i couldn't tell. I can understand how this would be a nice tool for an AI, but not how it works or how i am supposed to use it and would happily read some more about it in its own thread :)

Illiander42
Filter Inserter
Filter Inserter
Posts: 414
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Re: IA and FACTORIO

Post by Illiander42 »

Factorio combinators are turing complete. (So are factorio trains, factorio belts, and probably a few other things as well)

So we already have all the tools you need to write any program you care to. Go ham and write your AI.

We've also had the grey goo base that expands itself depending on what it's missing, with only 3 mods (Recursive blueprints, automatic trains, and I think it used LTN)

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2554
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: IA and FACTORIO

Post by FuryoftheStars »

Illiander42 wrote:
Sun Jan 21, 2024 3:30 pm
Factorio combinators are turing complete. (So are factorio trains, factorio belts, and probably a few other things as well)

So we already have all the tools you need to write any program you care to. Go ham and write your AI.

We've also had the grey goo base that expands itself depending on what it's missing, with only 3 mods (Recursive blueprints, automatic trains, and I think it used LTN)
This just conjured an image in my head of a scenario where there is no engineer (God controller) and the biters, etc are replaced by humans, cities, etc. :shock: Not sure if that's good or bad! :lol:
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

Illiander42
Filter Inserter
Filter Inserter
Posts: 414
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Re: IA and FACTORIO

Post by Illiander42 »

FuryoftheStars wrote:
Sun Jan 21, 2024 3:52 pm
Illiander42 wrote:
Sun Jan 21, 2024 3:30 pm
Factorio combinators are turing complete. (So are factorio trains, factorio belts, and probably a few other things as well)

So we already have all the tools you need to write any program you care to. Go ham and write your AI.

We've also had the grey goo base that expands itself depending on what it's missing, with only 3 mods (Recursive blueprints, automatic trains, and I think it used LTN)
This just conjured an image in my head of a scenario where there is no engineer (God controller) and the biters, etc are replaced by humans, cities, etc. :shock: Not sure if that's good or bad! :lol:
Brave New World (which is going to get a lot less hacky in 2.0) plus the Starcraft Terran mod.

Have fun :)

Qon
Smart Inserter
Smart Inserter
Posts: 2118
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: IA and FACTORIO

Post by Qon »

Illiander42 wrote:
Sun Jan 21, 2024 3:30 pm
Factorio combinators are turing complete. (So are factorio trains, factorio belts, and probably a few other things as well)
I have actually planned to make computers out of trains, belts and a few other things...
The electric network lets electricity flow to consumers from any producer. This is an OR gate.
Pumps require electricity to work and can be used to turn off steam engines when powered by pumping away water from boilers or steam from steam engines. With this I can make a NOT gate very similar to the operations of real world electromechanical relays:

The blueprint contains cheat entities from /editor mode for conveniently creating and disposing of fuel and fluids, but it's possible to handle the logistics of those without cheats. It has no combinators or circuit conditions. I should ideally be placed in editor mode with instant blueprint placement to get reproducible results, and the rotation of it matters both for placement and for creation. I did manage to have give it a much faster switching speed in one direction in an earlier iteration but somehow it is now slow, and because of the fluid simulation being so influenced by build order it is quite annoying trying to iterate on designs.
Illiander42 wrote:
Sun Jan 21, 2024 3:30 pm
So we already have all the tools you need to write any program you care to. Go ham and write your AI.
Turing completeness doesn't really make it practically possible. Though my Combinassembly language is an attempt at bridging that gap. Combinators are kind of slow but anything else is orders of magnitude slower :)
The earlier version of the electric NOT gate had a 3 tick delay to turn off and like 28 ticks to turn on (I might be mixing up on/off), 3 ticks is pretty decent though it will fall behind combinators by a lot because operations like addition will require chains of many NOT gates. And with 28 ticks in other toggle direction the average reaction is like 15 tick delay, really bad. Then suddenly after optimizing and engineering it for reliability it for some reason takes like 75 ticks to turn off instead, more than a second. And the average of on + off is like 50 ticks of delay now, horrible. But trains or belts are orders of magnitude worse still though so... But I wouldn't recommend creating an AI with electric network anyways.
Illiander42 wrote:
Sun Jan 21, 2024 3:30 pm
We've also had the grey goo base that expands itself depending on what it's missing, with only 3 mods (Recursive blueprints, automatic trains, and I think it used LTN)
Grey Goo is impressive for its time, but it is quite limited in what it accomplishes. And later attempts have had other limitations that make them worse in other aspects. Which is why I think a proper complete solution should be made. An AI that does expansion, new mines, expands power production, expands item production and calculates what recipes to prioritize production increase of, configures and designs production cells, solves base defense, clears land from native infestation, can expand in all directions. Etc.

Illiander42
Filter Inserter
Filter Inserter
Posts: 414
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Re: IA and FACTORIO

Post by Illiander42 »

Qon wrote:
Sun Jan 21, 2024 7:41 pm
Illiander42 wrote:
Sun Jan 21, 2024 3:30 pm
Factorio combinators are turing complete. (So are factorio trains, factorio belts, and probably a few other things as well)
I have actually planned to make computers out of trains, belts and a few other things...
The electric network lets electricity flow to consumers from any producer. This is an OR gate.
Pumps require electricity to work and can be used to turn off steam engines when powered by pumping away water from boilers or steam from steam engines. With this I can make a NOT gate very similar to the operations of real world electromechanical relays:

The blueprint contains cheat entities from /editor mode for conveniently creating and disposing of fuel and fluids, but it's possible to handle the logistics of those without cheats. It has no combinators or circuit conditions. I should ideally be placed in editor mode with instant blueprint placement to get reproducible results, and the rotation of it matters both for placement and for creation. I did manage to have give it a much faster switching speed in one direction in an earlier iteration but somehow it is now slow, and because of the fluid simulation being so influenced by build order it is quite annoying trying to iterate on designs.
And that gives you a NOR gate, if you can sync that to a clock that gives you another turing complete system.

Seriously. Well done on that.
Qon wrote:
Sun Jan 21, 2024 7:41 pm
Illiander42 wrote:
Sun Jan 21, 2024 3:30 pm
So we already have all the tools you need to write any program you care to. Go ham and write your AI.
Turing completeness doesn't really make it practically possible. Though my Combinassembly language is an attempt at bridging that gap. Combinators are kind of slow but anything else is orders of magnitude slower :)
The earlier version of the electric NOT gate had a 3 tick delay to turn off and like 28 ticks to turn on (I might be mixing up on/off), 3 ticks is pretty decent though it will fall behind combinators by a lot because operations like addition will require chains of many NOT gates. And with 28 ticks in other toggle direction the average reaction is like 15 tick delay, really bad. Then suddenly after optimizing and engineering it for reliability it for some reason takes like 75 ticks to turn off instead, more than a second. And the average of on + off is like 50 ticks of delay now, horrible. But trains or belts are orders of magnitude worse still though so... But I wouldn't recommend creating an AI with electric network anyways.
Turing machines have no concept of time, just transitions. ;p
Qon wrote:
Sun Jan 21, 2024 7:41 pm
Illiander42 wrote:
Sun Jan 21, 2024 3:30 pm
We've also had the grey goo base that expands itself depending on what it's missing, with only 3 mods (Recursive blueprints, automatic trains, and I think it used LTN)
Grey Goo is impressive for its time, but it is quite limited in what it accomplishes. And later attempts have had other limitations that make them worse in other aspects. Which is why I think a proper complete solution should be made. An AI that does expansion, new mines, expands power production, expands item production and calculates what recipes to prioritize production increase of, configures and designs production cells, solves base defense, clears land from native infestation, can expand in all directions. Etc.
I was about to start working on that (Symmetric multi-processing, too), then we got told about new rails. Which would mean I'd have to redesign all the blueprints.

It doesn't need anything even approaching an AI. You can even have it kick off as soon as you have construction bots, combinators and trains.

With the new stuff from FFFs you only need Recursive Blueprints and Automatic Trains for mods, and I could probably do it with only a few blueprints (Blueprint book provider (for SMP), wall, wall expander, mining, oil mining, steam power, nuclear power, blue assember, green/yellow assembler, chem plant, oil refinery, centrefuge, science) The blueprint provider would need to be unique, everything else could auto-configure.

Without FFF 2.0 stuff, you'd also want an LTN mod, and lots more blueprints, because you'd need one for each recipie. And finding water becomes harder.

Grey Goo isn't hard in principle, it's just a bit of a slog to put together without wired assemblers. I fully intend to do one after I've figured out how to do multi-planet grey goo in 2.0. (I've got a sketch of all the bits needed for a no SA grey goo already)

Post Reply

Return to “Ideas and Suggestions”