R-O-C-K-E-T / Factorio-SAT

Enhancing the Factorio experience with SAT solvers
GNU General Public License v3.0
633 stars 16 forks source link

How to make networks? Or are there more networks somewhere above 10x10? #13

Closed qtqgyt closed 1 year ago

qtqgyt commented 1 year ago

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?

R-O-C-K-E-T commented 1 year ago

This post is a good place to start if you want to understand the networks that drive balancers.

As to the network format that Factorio-SAT uses. Each line represents a single splitter the first 2 numbers are the colours the splitter takes as input and the last 2 numbers are the colours the splitter produces as output. A -1 represents a disconnected input/output. All colours must appear the same number of times as an input and output except for the overall balancer input and output colours. For example a 1-4 balancer is:

# Input splitter
-1 0 1 1
# Output splitters that are feed by the input
-1 1 2 2
-1 1 2 2

To construct your 1-17 balancer I would start with a 2-3 balancer feeding 3 1-6 balancers with the 18th output wrapping back into the 2 input. A simple balancer built using this design is shown below. Framework

To convert these sub-balancers into a single balancer network, merge the networks for the sub-balancers into a single network. Then fix up the colours to feed the output of the 2-3 into the 3 1-6 balancers and prevent the 1-6 balancers from feeding across each other.

# 2-3
0 13 1 1
-1 3 2 2
2 1 3 3
2 1 3 3
# 1-6
3 10 4 4
-1 4 5 5
-1 4 5 10
-1 5 13 13
-1 5 13 13
-1 5 13 13
# 1-6
3 11 6 6
-1 6 7 7
-1 6 7 11
-1 7 13 13
-1 7 13 13
# 1-6
-1 7 13 13
3 12 8 8
-1 8 9 9
-1 8 9 12
-1 9 13 13
-1 9 13 13
-1 9 13 13

Plugging this into belt_balancer yields a 6 tile wide balancer.

However plugging the problem into belt_balancer_net_free (which as its name might suggest doesn't require a network) yields a balancer that's 1 tile shorter. There's clearly some network construction knowledge that I'm missing. This alternative solver still has some kinks to iron out and it is much slower. Especially on problems harder than n-n, 1-n or n-1. Final

0eNqlWe1u4jAQfBf/TqvEXn8kr3KqTtBaVSQIURJORSjvfgRKQU2ctXd/IRDM7tg744k5i+3u6NuubgZRnUX9fmh6Uf05i77+bDa76bPh1HpRiXrwe5GJZrOf3vmvtvN9/9K3u3oYfCfGTNTNh/8SVTFm0T8fuk3Tt4dueNn63fAEIse3TPhmqIfa3xq6vjn9bY777aVcVWBYmWgP/eXnh2bq4gKpVPGqM3ESFRjzqsepzV+gMsxvAU5+g9llMEXoUGEdQlKHsN6hJnQosQ4NAVRjoDaJtlmn7QgdAtZhSQC1GGiRJ/F267wLimYM2uNcNMeLhrvP7nB5DeKWP7hTt9ndJg7HoT1ORjCvQ9FTiXYPBFSHohKUBag7FQRpQY6iJmkLCmTGCOIC1PUKgroAdSqZpC5Q68wlQV2AGp+UBFTUrKRKYq4R5gQNAep9kqIh1K2kSWJuEeaWlULKq/N91J1/v30Dlmo40pFfBjouSW4twz2bCO9WaefYXWkuEKwKVsSYMZBLNWin2qOKm1X5Wae6CS2TYiUTF0UMWEElMFZKJ22wRTbYpMW9e3c2j+BvmXGFJgDHrLoyTitVaWJ3MVyDQww5K/sERgKKtJSSMhKQ9Nj3lKjKCGzFykPzDViqkfRQCICstKYMDUje0BhWeIpyPrCk0BNwPHCs0BN19EPJqhHYYJ0We03KuGvWtYwtYvZRS1aNPKoG6/ImkgeQ3FmtMMGFptMOavmgFEGIdfVzXbQlVMsJRUHUtFT9vORLaKzbn/m4LLm8yVk18hjDMawbokgeknOPE9pPo3gB63t9MPkYkmYfkWFhiSJynNHMqjklPRrDiS7BjbKUsBISnnGci6E4nzasy6c44dmctMM6Zq6Cw2xZN1ahLbGSE1rmy7XkIVbRIszvU2wRG1jxQk6r8pbd/u+qnv5dy8Q/3/W3KXMF2FJaU8rcKTmO/wHPgxEV