teoxoy / factorio-blueprint-editor

A feature-rich Factorio Blueprint Editor
https://fbe.teoxoy.com
MIT License
299 stars 61 forks source link

[BUG] Some pumpjacks are left disconnected after planner completes #254

Open joelverhagen opened 8 months ago

joelverhagen commented 8 months ago

Describe the bug

If you run the oil field generator on this blueprint, some pumpjacks don't get connected. 0eJyUlsluwzAMRP+FZx2sxeuvFEWRRSjUxorhpWgQ+N9rhToUiQCNj3HkZ4qaGepOx8tih9H5mbo7udPVT9S93Wlyn/5wCc/8obfU0bD0w9fh9E2C5tsQnrjZ9rQKcv5sf6mT67sg62c3O8uMx4/bh1/6ox23BSLBGq7T9sLVhy9tEN0Ium1L9cY9u9Ge+L9iFS84BeDKgnFlHqeR6irGNXmcAXBVrK7N40oAZ+QDp4o8rkJ6pxgn87gawdWMU3lcgxxFyThAKC3SuxrGyQIpr2WeAXiIL6RmHiBkiRhDxfoqgIc4w5RJnkrxEGvouN8aqA/yRoHz9pgD4SHu0FF/QLJIxB4m9q8FzgPyR5PkJXN5hz80EC4KmhusPw2ki1J4HjzzUv1T0ORg/WlkriH+MArnlfighHjVjvN9yj+T4tU79lsBPMgfUS9A/oWozO/XMA/IgyAFWC9AHmi5Q8+Af7XC89kA/g1LUb0YQH+h1WgeGGS/0Pzg833lbXfexz24+3eRFvRjxykuWP8AAAD//wMA5MG5Zw==

To Reproduce

Use the above blueprint and click "Generate" under "Oil Outpost Generator Settings"

Expected behavior A clear and concise description of what you expected to happen.

It is because the aloneGroups array is not empty at the end. The 5 pumpjacks here are in one leftover alone group. https://github.com/teoxoy/factorio-blueprint-editor/blob/83343e6a6c91608c43a823326fb16c01c934b4bd/packages/editor/src/core/generators/pipe.ts#L265

Screenshots

image

Desktop (please complete the following information):

sighnwaive commented 3 months ago

Picking this up to work. I found the root cause area, just nailing down the scenarios that cause it and then i'll have a patch up shortly.

sighnwaive commented 3 months ago

After looking at this a bit more, the pathing for the pipes does not quite support "backtracking" or "extra spacing" to connect pipe groups. The following blueprint, while similar, moves 1 pumpjack over, and all pumpjacks are now connecting. This is due to the fact that pathing can be handled with the current algorithms.

0eJytm1tvpDgQhf8LzzCyDTaQx/0bq2iVC5plt2/qdI82ivq/L6SFSSibOuXhYaSZTOccX+o7FOD+yJ531+507g+X7OEj61+Oh7fs4c+P7K3/eXjajT+7vJ+67CHrL90+y7PD03781+m6P/3z9PJvdsuz/vDa/Zc96NtjnnWHS3/pu7vG5z/e/zpc98/defgA/e08Ox3fhl84HkanUeSHzbP37KHQzQ87aL/25+7l/v9V/jmGt/GTp/Px9Tr8/NegX+yHv++6oswezO2WE1uD2Jbe123lWwK+hfK+5dJXJfpWgK+Z52u28rWAb+Vt9dLWJNo6ZHut91VLX5foWyPL7Le33WqVG6SqPEUEotTZtsgqq6ht6uZqhazyZFtvZotEVTFDRDIj2RgJq3Ged1+7VVVpJKyaqG1qVWkkqwq/zNVW0ayRrIrbJq+yLKuIb/IyI1nl4SUXomRbJKvcZEuuQ8mbC2WVjvqm7q4RZdVm1yEDZdU0XWKbmlQGaqtUzDa5mYO6qqmoNmsyDBJUNuaaXFFITE0VReo4uaCQlJrmullGGSSjmphr8gpD7dS0xJtd9wwSUb6KN+suSiShPLOkm0qdbQkl1HS53axTLpGEmraW3o8k20IJNeWxJquc7ItEVP37tnwBVbEcdDkZtJXa9qduBRV6C6Cop+P1rESvFuiFuo2lXsPrVZLxtQI9YHyVEuiFsFrqaYEeaSQCegbXQ+RKXA6ZbYXLIZthcbnQE6alHMBGtXIRXsoBaFSxi2tATkAGuWgG5ARgAJxZgItSwK0FuCgFwwOwMAI5AIupk9DA3lqei/lZKbC5lgdj1kPGx5OhBCFleTKi904BNR4MhUeU5blQeEI5HguFB5TjoVB4PjmeCS1Q45EwAjUeiFKgxuNQ4kHseBhKPIcdz4Ig5xzPwqRGHlMH1HgW1m5clu8MeBZ8pwMMruZhkDSKNU+DlwO2teZxsJLJ8jxYQQDXPBBOcn2oeSRmPQDYmodi1gOCs+axmPWAWK95MJxgdxueDC8HrF7Dk+EExd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p2+1/aADAhw==

I'm going to talk with @teoxoy about this a bit, as i believe to "correct" this, we may have to update the algorithms quite a bit.

sighnwaive commented 3 months ago

Found a much smaller blueprint this happens on. Easier to reproduce and see.

0eJyV0ksOgjAQBuC7/OtqoIBKl17DGMNjYqpQGihGQri7FIQYN9Zd25l+6UynR1q0pGupDEQPmVWqgTj1aORVJYU9M50mCEhDJRhUUtqdbkt9S7I7BgapcnpC+MOZgZSRRtJsfOcy6KoZw5Wy7nhl420jhm5ejFIua8rmuPe2uotqy5Rq6zMHMvhD5E7i+kj+WwycRO4Ohk6gvxQd/BYjt6KXPjq0cWc/fhoP8TFNDA+qm+kKP/jhPub7kMdxEPsMRZLSOFs4rtnD8ALvbtJu
joelverhagen commented 3 months ago

@sighnwaive I was able to resolve the issue by allowing the FBE algorithm more retries: https://github.com/joelverhagen/FactorioTools/blob/ed60f85859df3dc4682553bc852b158833db6539/src/FactorioTools/OilField/Steps/AddPipes.1.FBE.cs#L197 (this is my C# implementation of the FBE algorithm for my own tool https://factorio-tools.vercel.app/oil-field). That might be an easy fix).

sighnwaive commented 3 months ago

OK, Found that during pipe generation, we don't generate any underground pipe for connection purposes. Underground pipe is only used to replace stretches of straight pipe. Will work to refactor this to use underground pipe as a method of connection on either side of a building as well. This will be done by generating all straight pip connections, then looping through remaining unconnected groups and finding the shorteste path of underground that is not blocked by a building to exit a state of lock-in.

sighnwaive commented 3 months ago

@sighnwaive I was able to resolve the issue by allowing the FBE algorithm more retries: https://github.com/joelverhagen/FactorioTools/blob/ed60f85859df3dc4682553bc852b158833db6539/src/FactorioTools/OilField/Steps/AddPipes.1.FBE.cs#L197 (this is my C# implementation of the FBE algorithm for my own tool https://factorio-tools.vercel.app/oil-field). That might be an easy fix).

The bigger issue here is that we don't actually use undergrounds as part of the pathing algorithm.

sighnwaive commented 3 months ago

As seen here: image The pipe group in the center would be invalid. The algorithm made the connection, but did not connect it to all other groups. Some changes need to be made to handle this situation as well as using underground to edit the area.