r-o-c-k-e-t / factorio-sat Goto Github PK
View Code? Open in Web Editor NEWEnhancing the Factorio experience with SAT solvers
License: GNU General Public License v3.0
Enhancing the Factorio experience with SAT solvers
License: GNU General Public License v3.0
Hi,
I read a little through the code and it seems like you're translating everything into CNF, which means you're potentially not using some of the more cutting edge solving techniques.
There are alternative approaches where, instead of writing a script in e.g., Python to generate clauses, you write your "constraints" into a language that is specifically designed to express those constraints. These languages are generally based on 1st order predicate logic. An example of such a system can be found here: https://potassco.org/doc/start/. There's other systems available, but not all of them are well-documented, since systems like these generally find no use outside of academia (yet :p).
The long and short of it is: there are constraint solving systems that allow you to write your clauses using not only boolean variables, but also constructs of other kinds, like numerical variables. The hope is that for the majority of the problems that deal with problems that feature numerical concepts (like grid coordinates), this extra expressive power allows a reasoner to more efficiently go through the search space.
If my assumptions above are correct, I'd take some time and prototype an encoding that could serve as an alternative. My time to spend on this is limited, so if you feel like me pointing you towards resources where you can learn this yourselves is more efficient, I could do that as well.
Could you provide some example commands to run from the root of the git repo? I'm really not sure what I'm doing, things are hanging forever with no indicator of progress.
Hi ! I have a very specific problem, I am trying to design a 8 to 12 balancer with an L shape and specifically placed outputs.
I decided to give a try to your project because I love the idea of it but I have trouble understanding how to use it,
I want to define exactly where my inputs and outputs are and let the algorithm find a solution from that,
Is it even possible ?
Thanks !
Hi, I have been trying to make a 1-17 balancer with factorio-sat, however, cannot find a network file for a 1-17 balancer. Can someone help me find this network file, or make my own?
Hi, im a using Windows 10 with Powershell and python3.9 and I have trouble with file encoding.
When saving/printing the app uses the 'utf-8-sig' encoding thus includes 2 bytes to specify the format (UTF-8 BOM).
But when reading utf-8 is assumed thus the parser fails.
Example with the README example :
python3.9.exe belt_balancer.py --fast --all networks/4x4 10 4 | python3.9.exe render.py
output :
pygame 2.1.2 (SDL 2.0.18, Python 3.9.13)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "D:\GitHub\Factorio-SAT\render.py", line 547, in <module>
solution = np.array(json.loads(input()), ndmin=2)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 335, in loads
raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
I can make it work by replacing line 547
solution = np.array(json.loads(input()), ndmin=2)
with
solution = np.array(json.loads(input().encode().decode('utf-8-sig')), ndmin=2)
(fix found here : https://www.howtosolutions.net/2019/04/python-fixing-unexpected-utf-8-bom-error-when-loading-json-data/)
But this is more like a workaround and dont fix the root issue.
The problem appear every time the app tries to read a file it itself wrote, for example when using the --partial argument, I did not find a workaround for this one.
I tried to launch the app with WSL Debian for comparison but the pip installation fails for reasons I am still investigating.
Space Exploration adds "Deep Space Transport Belts," splitters, and underground belts, which are expensive end-game belts that operate at twice the speed of vanilla blue belts. There are 8 different colors of belts but the actual belt / splitter items are functionally equivalent / interchangeable. The underground belts however only link to their own color, so you can have multiple underground segments in the same linear space where they would otherwise conflict. Additionally the underground belt range is 17 tiles where blue belts are only 9.
As a proof of concept I manually shrunk an 8-8 balancer using the alternative colors.
Left: Traditional 8-8 balancer, not TU, color-coded for structure
Middle: Shortened version with matching colors
Right: re-colored with 2 colors.
I've forked the repo to explore the possibility of improving other balancer designs with new constraints for the additional colors. I'd love some guidance on where I might start, or if you foresee any large hurdles I might run into.
Finally, as a separate issue, I got an error when running an example from the readme. I ran calculate_optimal compute --threads 1 8 length
and got ValueError: Wrong bound: 17
which I suspect is related to the DS belts. Thanks for any advice on this too!
Hi, first off this project is amazing! During my testing I've found an output for the 8x3 balancer that is longer than what is in Raynquist's book. See the attached picture.
I can only guess why this might be, so I have some questions. Is Factorio-SAT exhaustive in its search of shorter balancers if it finds no solution? Or would this be a something to do with the constraints? Will Factorio-SAT allow a loop next to the exit belts like the current 8x3 best?
Thanks!
For balancers that contain empty splitter outputs (downsizing balancers), being able to place perpendicular underground entrance/exit next to such outputs is an important layout trick. The splitters are prevented from side-loading onto the undergrounds by setting output filters, thus preserving the desired 2-1 splitter behavior.
Here is an example 6-2 balancer that beats Factorio-SAT's solution:
The associated splitter output filters need not be in the program output; I can add them by hand.
Should this negatively impact performance, the functionality can be selectively enabled only for networks containing 2-1 splitters. Conversely, similar configurations involving empty splitter inputs can also be selectively disabled for networks that do not contain 1-2 splitters if doing so improves performance.
Hello,
I am rather out of my depth here, but I was messing around with different solvers to see if any were faster or slower than others. I found a couple GPU accelerated solvers https://github.com/nicolasprevot/GpuShareSat and https://github.com/muhos/ParaFROST, however they do no support input on STDIN. I thought it would be interesting to try these. Is it possible to output to a .cnf file to use these solvers?
networks.zip
Most balancers of the type m-n
where 1 <= m, n <= 64
are included in my files. I would have used Factorio-SAT to create blueprints for a blueprint book and exported that book to a string, but I couldn't even generate a blueprint for a single network because it was taking too long. So, I wish to share the network files so that if anyone wants to use them, they're available.
My balancer networks are not optimized to use the fewest number of splitters, but they are at least proven to have no throughput issues when not all of their inputs and outputs are used. For example, a 2-4 balancer that has exactly three splitters has throughput issues when feeding two input belts but using only two output belts that both come from the same splitter. My network file for the 2-4 balancer enables full throughput in that scenario. I think that's called UTU, but I may be mistaken.
Where should I publish the files so that others can make use of them? Separate repository? Would people be able to find that? I'd want them to be easy to find for anyone who's looking for them. Thanks!
I've attached a 2.77 MB compressed file to this issue so that they're at least sitting somewhere for now until it can be published to a better location.
FSAT generated a beautiful solution for 2-3. But for 3-2, which should simply be the reverse of 2-3 if nothing else, it generated a worse solution. I'm guessing undergrounds are not allowed in front of unused splitter outputs? There are a couple of underground orientations where such a layout should be allowed as no sideloading is actually occurring.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.