Latest Posts

Topic: Build plots calculations change

Nordfriese
Avatar
Topic Opener
Joined: 2017-01-17, 18:07
Posts: 1929
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2020-08-04, 22:41

There is currently a bug where placing more lava or similar bad terrains enables building spaces:

In order to fix this, we want to always disable the building space in the situation illustrated in the image.
(Always enabling it instead would cause a serious bug about players sealing themselves off completely to regress, so this is not an option.)

This might cause bottlenecks or similar bad side-effects on some official maps (e.g. Sun of Fire, Long Long Way, Fjords) so we'd appreciate it if people who know the maps well could give their thoughts on which maps may need some editing to make them balanced again after this change face-smile.png

Edited: 2020-08-04, 22:43

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-08-05, 08:45

I have tried to write a small lua script which count all building plots for a map loaded in editor:

map = wl.Editor().map

small_count = 0
medium_count = 0
big_count = 0
mine_count = 0

for x=0, map.width-1 do
    for y=0, map.height -1 do
        f = map:get_field(x, y)
        if f:has_caps('small') then
            small_count = small_count + 1
        end
        if f:has_caps('medium') then
            medium_count = medium_count + 1
        end
        if f:has_caps('big') then
            big_count = big_count + 1
        end
        if f:has_caps('mine') then
            mine_count = mine_count + 1
        end
    end
end

print("Amount of building plots:")
print("Small:  ", small_count)
print("Medium: ", medium_count)
print("Big:    ", big_count)
print("Mines:  ", mine_count)

If this script can be run over all maps automatically it should be possible to estimate the result of the proposed change.

But the result is surprising... for a map with 1 big plot, 4 medium plots, 2 mine plots and no immovables the result is:

Amount of building plots:
Small:          1
Medium:         5
Big:            1
Mines:          2

Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
JanO
Avatar
Joined: 2015-08-02, 11:56
Posts: 177
Ranking
At home in WL-forums
Posted at: 2020-08-05, 08:57

Does the result change if you switch the order into first count big, then medium and small in the end?


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2020-08-05, 11:05

Nordfriese wrote:

This might cause bottlenecks or similar bad side-effects on some official maps (Long Long Way) so we'd appreciate it if people who know the maps well could give their thoughts on which maps may need some editing to make them balanced again after this change face-smile.png

Is there any possibility to estimate how many building spots would be removed / added after the change? I am the "inventor" of Long Long Way and it should not be affected by that, but I would like to know how much it CAN be affected (by numbers of spots). Unfortunately it can be affected by the fact that port spaces calculation changed since map creation.


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-08-05, 11:44

You could try something like this (not tested by me):

I have tried to write a small lua script which count all building plots for a map loaded in editor:

map = wl.Editor().map

small_count = 0
medium_count = 0
big_count = 0
mine_count = 0

for x=0, map.width-1 do
    for y=0, map.height -1 do
        f = map:get_field(x, y)
        if f:has_caps('mine') then
            mine_count = mine_count + 1
        else if f:has_caps('big') then
            big_count = big_count + 1
        else if f:has_caps('medium') then
            medium_count = medium_count + 1
        else if f:has_caps('small') then
            small_count = small_count + 1
        end

    end
end

print("Amount of building plots:")
print("Small:  ", small_count)
print("Medium: ", medium_count)
print("Big:    ", big_count)
print("Mines:  ", mine_count)

This will count the port spaces simply as big plots, but that should be fine for this purpose.


Busy indexing nil values

Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2020-08-05, 13:41

GunChleoc wrote:

You could try something like this (...)

This will count the port spaces simply as big plots, but that should be fine for this purpose.

Yes, but it will not show how many plots will be missing with proposed change. Is there any possibility to check nearby nodes if they contain any lava / ice?


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-08-05, 16:11

In order to show what's missing, you'd have to run this both with the master branch and the feature branch and then compare the results.


Busy indexing nil values

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-08-05, 19:10

Is there any possibility to check nearby nodes if they contain any lava / ice?

Yes, this can be done by checking the neighbores of a field

In order to show what's missing, you'd have to run this both with the master branch and the feature branch and then compare the results.

This was my idea... although it's a bit boring to open the debug console and type dofile('path/to/file.lua') each time a new map was loaded face-sad.png

This script seems to work properly now:

map = wl.Editor().map

small_count = 0
medium_count = 0
big_count = 0
mine_count = 0

for x=0, map.width-1 do
    for y=0, map.height -1 do
        f = map:get_field(x, y)
        if f:has_max_caps('mine') then
            mine_count = mine_count + 1
        elseif f:has_max_caps('big') then
            big_count = big_count + 1
        elseif f:has_max_caps('medium') then
            medium_count = medium_count + 1
        elseif f:has_max_caps('small') then
            small_count = small_count + 1
        end
    end
end

print("Amount of building plots:")
print("Small:  ", small_count)
print("Medium: ", medium_count)
print("Big:    ", big_count)
print("Mines:  ", mine_count)

I am compiling the nodacapsmath-branch now and will provide some comparisons later. Any special maps to compare?


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2020-08-05, 20:02

Here are the results of the maps mentioned in the first post:

Map Size Branch master Branch nodecapsmath
Sun fo fire (shipped) Small 2277 2280
Medium 695 586
Big 4320 4291
Mines 5609 5157
Long long way v2 (shipped) Small 573 533
Medium 2896 2715
Big 9178 9181
Mines 2698 2680
Fjords 1.2 Small 83 83
Medium 238 238
Big 94 94
Mines 1148 1026

Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2020-08-06, 01:08

kaputtnik wrote:

Here are the results of the maps mentioned in the first post:

Map Size Branch master Branch nodecapsmath
Long long way v2 (shipped) Big 9178 9181

A bit strange: more big places than before?
Anyway, I will probably have to revise the map and fix it if needed face-wink.png .


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote