[1.1.107] starting_points far from 0,0 cause weird starting resource layout (not a bug?)

Post your bugs and problems so we can fix them.
Post Reply
Oarc
Fast Inserter
Fast Inserter
Posts: 101
Joined: Sun Sep 18, 2016 2:04 pm
Contact:

[1.1.107] starting_points far from 0,0 cause weird starting resource layout (not a bug?)

Post by Oarc »

I was hesitant to file this as a bug as it isn't a real gameplay issue, just makes for a weird starting resource layout compared to the default.

My expectation is that if I add more starting points (or change their location), the feel of each starting point should generally conform to the same experience as a normal vanilla game starting point. I think if you look at the pictures, I'm hoping you'll agree there is a significant and unexpected difference?

I stumbled across this when trying to add more starting points for a multiplayer scenario a long long time ago, so I assume this behavior of the map gen for starting resources has been around awhile? (Or possibly I'm just doing something wrong/weird?)


If you set a single starting_point to (10000,10000) for example, the starter resources become weirdly fragmented. Instead of the more common well defined set of 4 starting resource patches with the occasional extra bits, you can see upwards of 4+ smaller patches of each resource type.
I've tried playing around with different numbers of starting points and different distances between the starting areas (like 2000 vs 20000 distance units between equally spaces spawn points), but can't really notice a specific pattern other than anything further from 0,0 gets weird.

I attached a few pictures and code snippets to show what I see and what I'm doing.

Example of the normal spawn with only a single starting_point at 0,0:
VanillaSpawnSingle.png
VanillaSpawnSingle.png (118.89 KiB) Viewed 162 times
Example of a spawn (1 of 25, spaced equally in a grid, each 2000 tiles apart):
VanillaSpawnMulti_25.png
VanillaSpawnMulti_25.png (314.15 KiB) Viewed 162 times
Another example of a single spawn (1 starting_point, at x=10000,y=10000):
VanillaSpawnSingle_10000x10000y.png
VanillaSpawnSingle_10000x10000y.png (143.6 KiB) Viewed 162 times

Test scenario code is pretty simple:

Code: Select all

GAME_SURFACE_NAME="oarc"
CHUNK_SIZE = 32

script.on_init(function(event)

    -- Get starting surface settings.
    local nauvis_settings =  game.surfaces["nauvis"].map_gen_settings

    local count = 2
    local spacing = 20000

    local points = {}
        
    -- OR test for a single offset spawn point instead of laying out a bunch
    -- local points = {{x=10000,y=1000}}

    -- This part isn't important for the bug report, it's just what I was using to space points around in a grid. I tried to cut everything else not relevant.
    local sqrt_count = math.ceil(math.sqrt(count))
    if (sqrt_count % 2 == 0) then
        sqrt_count = sqrt_count + 1
    end

    local sqrt_half = math.floor((sqrt_count-1)/2)

    -- This should give me points centered around 0,0 I think.
    for i=-sqrt_half,sqrt_half,1 do
        for j=-sqrt_half,sqrt_half,1 do
            local x_pos = (i*spacing)
            x_pos = x_pos - (x_pos % CHUNK_SIZE) + (CHUNK_SIZE/2)
            local y_pos = (j*spacing)
            y_pos = y_pos - (y_pos % CHUNK_SIZE) + (CHUNK_SIZE/2)

            table.insert(points, {x=x_pos,y=y_pos})
        end
    end

    nauvis_settings.starting_points = points

    -- Create new game surface
    local s = game.create_surface(GAME_SURFACE_NAME, nauvis_settings)

end)

script.on_event(defines.events.on_player_created, function(event)
    local player = game.players[event.player_index]

    -- Move the player to the game surface immediately.
    player.teleport({x=0,y=0}, GAME_SURFACE_NAME)
end)

Post Reply

Return to “Bug Reports”