Generated landmine blueprints

Post pictures and videos of your factories.
If possible, please post also the blueprints/maps of your creations!
For art/design etc. you can go to Fan Art.

Post Reply
PostmodernPrometheus
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Jul 20, 2023 4:03 am
Contact:

Generated landmine blueprints

Post by PostmodernPrometheus »

Landmine alignment
Landmines are one of the few entities that don't align to the 1x1 meter grid (the others being locomotives and cargo/fluid/artillery wagons).

This can be a pain if you're trying to create a complex defensive pattern with landmines and dragon's teeth. Here's a post I found that provides a centered grid-aligned mine blueprint.
Landmine Size
Just centering landmines isn't really in the spirit of optimization. So how close can we lay landmines? I found through experimentation that the diameter D of a landmine is .80078125 (factorio-generated train/landmine blueprints have 8 fractional decimal places). Factorio will accept blueprints with closer landmines but once the first landmine is laid down your construction bot won't be able to place the second. This blueprint demonstrates two pair of landmines .80078125 and .80078124 meters apart - only 3 landmines will place because two of them are too closely spaced.

Spidertrons and landmines
Spidertrons can't cross tightly-laid landmines, similar to fully-packed walls/pipes/rails (reference). Here's an 11x11 landmine (9x9 meter) blueprint. If you tile it, spidertrons can't cross.
spidertron_stretch_lol.png
spidertron_stretch_lol.png (1.97 MiB) Viewed 1108 times
Landmine/circle packing
We should be able to lay landmines even tighter - in an infinite 2d space the tightest circle packing method is to alternate rows offset by sin(30°)*D==.5*D and separated from the previous row by cos(30°)*D~=.86602540*D. Sadly, this doesn't work - when we offset rows by .5*D we still have to separate rows by D. In other words, landmines occupy a square not a circle and D is the width not the diameter.
Landmine implementation details
As I was experimenting with circle packing I realized I could find the landmine dimensions using the easier but less fun method - look at the game's lua code. entities.lua lists a land-mine collision box as [-.4,-.4] to [.4,.4]. Of course that doesn't square with my experimental data - my best guess is that the collision detection disallows edges that equal each other and factorio only resolves to 1/128 decimeter (1/1280==0.00078125). I didn't find a way for this to relate to an IEEE 754 float or double resolution.
Perfectly packed Landmines
If you want to pack landmines perfectly and be grid-aligned, lay a landmine field of size 256x256 landmines, 205x205 meters (.80078125==205/256). I do not recommend you do this, that's 2^16==65536 landmines. I couldn't upload this blueprint to factorioprints and I didn't even try here. :P

mwls
Burner Inserter
Burner Inserter
Posts: 10
Joined: Wed Jan 18, 2023 6:00 am
Contact:

Re: Generated landmine blueprints

Post by mwls »

PostmodernPrometheus wrote:
Mon Sep 25, 2023 3:46 am
Landmine implementation details
As I was experimenting with circle packing I realized I could find the landmine dimensions using the easier but less fun method - look at the game's lua code. entities.lua lists a land-mine collision box as [-.4,-.4] to [.4,.4]. Of course that doesn't square with my experimental data - my best guess is that the collision detection disallows edges that equal each other and factorio only resolves to 1/128 decimeter (1/1280==0.00078125). I didn't find a way for this to relate to an IEEE 754 float or double resolution.
Map positions are 32-bit fixed point numbers with 8 bits for the fractional part, so the smallest representable distance in Factorio is 1/256 of a tile. I don't know the specifics of how rounding and collision detection are implemented, but it makes sense that the "radius" of the bounding box would round from 0.4 to 102/256, and that the centers would have to be 205/256 apart to avoid their boxes touching at the edges.

If your blueprint works with .80078125 but not .80078124 then it sounds like the decimal to binary fixed point conversion always rounds down. (Towards 0 or towards negative infinity?)

I wouldn't be surprised if there's already a deep dive into this topic somewhere on the forum.

PostmodernPrometheus
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Jul 20, 2023 4:03 am
Contact:

Re: Generated landmine blueprints

Post by PostmodernPrometheus »

mwls wrote:
Mon Sep 25, 2023 10:38 pm
Map positions are 32-bit fixed point numbers with 8 bits for the fractional part, so the smallest representable distance in Factorio is 1/256 of a tile. I don't know the specifics of how rounding and collision detection are implemented, but it makes sense that the "radius" of the bounding box would round from 0.4 to 102/256, and that the centers would have to be 205/256 apart to avoid their boxes touching at the edges.

If your blueprint works with .80078125 but not .80078124 then it sounds like the decimal to binary fixed point conversion always rounds down. (Towards 0 or towards negative infinity?)

I wouldn't be surprised if there's already a deep dive into this topic somewhere on the forum.
Thanks for the link! This was my first foray into some of the more technical aspects of Factorio. I'll have to look for a deep dive about map positioning and collision detection. Dividing the grid into 1/256 also explains why blueprints have 8 decimal digits - lets you represent 1/256.

Off-grid entities might also be require to have an odd height/width so that they have an unambiguous single center point, another explanation for the 205/256 not 204/256.

I'll have to try some negative values to see if it's rounding down or truncation.

Post Reply

Return to “Show your Creations”