Ribbon Maze

by H8UL

The maze itself is destined to be automated.

Overhaul
4 years ago
0.16 - 0.17
50

b Lots of straights [0.7.4]

4 years ago

hey, im playing in 0.17.36 but the maze seems to go straight north without a way back like this(https://imgur.com/a/UZUBaQL)
i triede running to the end with higher walking speed but after 10 minutes of running at speed 10 still no way back down.

this is with default settings but i tried it on different maps with different settings but every time the same thing happens.
I have no clue how to fix it and i hope you can.

4 years ago

Thanks for your report.

The fix to basic maths differences between Linux and Windows, which I made in 0.7.4, has unintended consequences, this being one of them.

I've backed this out and so now we have two problems, there are still desyncs between Linux and Windows, and now players will have stretches like this in any map generation that has happened.

This is unfortunate but it does emphasize why experimental really is just that -- both Factorio 0.17 and Ribbon Maze 0.7 are risky for general play!

4 years ago

Which math makes this difference?

4 years ago

Arguably, isn't a difference in the math experienced by the Lua interpreter that varies by platform a bug in Factorio, not your mod?

4 years ago

Lua 5.2 doesn't do integers. It has bit32, which I use, but it doesn't provide 32-bit multiplication. However it seemed to work. However, not portably. I fixed the desync by emulating 32 bit multiplication, because normal multiplication behaves differently on Linux and Windows when combined with bit32.

Unfortunately I also need 64-bit multiplication for one step. I forgot this and used the 32-bit function, and it borked map generation.

Scripting languages make basic integral maths way harder than it needs to be. I might need to ask the devs to add in some integer support. But chances they would consider it a priority seem slim.

4 years ago

Arguably, isn't a difference in the math experienced by the Lua interpreter that varies by platform a bug in Factorio, not your mod?

I'd like to think so!

4 years ago
4 years ago
(updated 4 years ago)

Why no just
’’’a = (0.001664525 * 2.031137496+1.013904223) * 10^9’’’

4 years ago

Overflowing is actually intentional. I have a workaround by writing a 32-bit maths multiplication function:

local function mul32(a, b)
    a = bit32.band(a, 0xffffffff);
    b = bit32.band(b, 0xffffffff);
    local ah = bit32.rshift(a, 16);
    local bh = bit32.rshift(b, 16);
    local al = bit32.band(a, 0xffff);
    local bl = bit32.band(b, 0xffff);
    local high = bit32.band((ah * bl) + (al * bh), 0xffff);
    return bit32.band((high * 0x10000) + (al * bl), 0xffffffff);
end

It gets pathological from here because I might need to compose 64-bit multiplication out of this, given that I can't rely on Lua to behave with large numbers.

4 years ago

I've made my own maze mod Mazing, it doesn't use any of this math. Why are you need so huge numbers?

4 years ago
(updated 4 years ago)

I have provided my own RNG. The built in deterministic LuaRandomGenerator is limiting and has poor behaviour imho (try using two neighbouring seeds -- assuming it hasn't changed since 0.16.51 you end up with the same numbers). There is also lot more I am procedurally generating than the maze, many other random properties are required, e.g. dead end resources, and I want these to be deterministic and unaffected by the order of maze exploration.

Reliable bit manipulation isn't an odd thing to expect on a digital computer.

4 years ago
(updated 4 years ago)

I just took a look at Mazing and I see it uses math.random. So the problem with that is it depends on the tick.

I want a map seed to give the same map based upon seed right down to the ore in each dead end tile, regardless of the order of charting.

That perhaps makes it clearer why I went for my own RNG.

4 years ago

So our amazing devs... they fixed the platform difference for the next release within a day. Once the changes are out I'll make a test for the PRNG, to prove it's the same and it's reliable on all platforms.

It's been a tough bug to deal with but if it's led to an fix in core Factorio, then it's been worth it :D

4 years ago

Yeah, I'vmade also the mod New Islands, where I made my own rng generator, see control.lua:enigma

4 years ago
(updated 4 years ago)

Cool! See I think RNG are interesting. Given the engineering mentality of Factorio players, I was rather expecting more people to take an interest in the discussion I started around the built in generator: https://forums.factorio.com/viewtopic.php?f=34&t=70588

That discussion indentified what RNG Factorio uses, and that the seed handling is bugged. I'm satisfied that I was right to avoid it for heavy procedural generation.

But I made an error in not spotting that Lua 5.2 makes weak promises about 64-bit numbers, even when on a 64-bit platform.

Devs are fixing that, but in hindsight I'd have been better off picking an RNG that only needs 32-bit maths, JKISS-32 being a highly regarded choice https://github.com/bhickey/librng/blob/master/src/jkiss32.cpp

4 years ago

Pushed an update that forces Factorio > 0.17.38.

Tested on Windows and Linux and for the same map seed, all aspects of the map are now identical in every detail, as intended :)

4 years ago

Did zou tried multiplayer?

4 years ago

Not multiplayer, but the desync was definitely narrowed down to a platform difference so I have high confidence by testing the individual platforms :)

New response