Calculations for Territorial winconditions are wrong

Bug #1810062 reported by Toni Förster
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Undecided
Unassigned

Bug Description

I noticed this while testing some changes I made. I played the map Crater against a computer. According to the normal stats had almost 2000 field units. But in the win-condition calculations is was only 1600. Although he had more then 50% of the total map (1724 was the 50% mark) He still wasn't winning.

This can easily be tested create an empty map with only 1 Player in the editor. Open the map in MP with Territorial.

The normal stats say 271 but the win conditions report only 264.

The problem is that the win conditions use only the buildable fields for calculation and not the fields a player actually owns. So fields that are occupied by buildings, mountains, immovables and so on are not considered for calculation.

Tags: wincondition

Related branches

Toni Förster (stonerl)
description: updated
Toni Förster (stonerl)
description: updated
description: updated
Toni Förster (stonerl)
description: updated
Revision history for this message
kaputtnik (franku) wrote :

See also bug 1622307, and bug 1617576

Revision history for this message
Toni Förster (stonerl) wrote :

I fixed it in my branch. Basically immovables need to be considered when calculating buildable fields for the first time. The only problem left is the fields covered by the headquarter. They are still not counted.

The problem with Glacier Lake (bug 1622307) is that the author of the map used snow with the attribute arable for regions that can never be reached.

Revision history for this message
Toni Förster (stonerl) wrote :

It's not the headquarter. It's the street in front of the headquarter. Especially when using the starting condition village or fortified village this accounts for some missing points.

f:has_caps("walkable")

Would add those fields to.

This would also add fields that are walkable but not arable like beaches, swamps on the other hand not.

Revision history for this message
kaputtnik (franku) wrote :

Launchpad shows you branch as empty. Can you please upload your branch again? Then try to wait until the branch is processed before making any action, like linking bugs or doing a merge proposal. You can see if a branch is finally processed on the page https://code.launchpad.net/widelands in the last column (a revision number shows up then).

Revision history for this message
Toni Förster (stonerl) wrote :

Launchpad seems to be very finicky lately. I pushed the branch again. With a new approach. I will explain in detail in the merge request.

Toni Förster (stonerl)
Changed in widelands:
assignee: nobody → Toni Förster (stonerl)
status: New → In Progress
Revision history for this message
kaputtnik (franku) wrote :

As discussed in the merge request, we may want an other solution for the territorial winconditions:

The idea is to calculate reachable fields when a map is saved in the editor and put either a table of that fields, or just save the amount of the fields in a file (e.g. elemental).

The territorial winconditions could then read the value from the file to calculate 50% percent of a map.

Revision history for this message
hessenfarmer (stephan-lutz) wrote :

+1 for saving the reachable (or perhaps valuable) fields with the map.

However if the value is not present in the map we should calculate them when either:

1. loading a map in the game (might be implemented in C++ using the same algorithm as in the editor) or
2. selecting one of the territorial starting conditions (to be done probably in lua)

Reason: There are a lot of maps out there (user maps on the homepage as well as still supported S2 maps) for which we should keep some compatibility.

Revision history for this message
kaputtnik (franku) wrote :

I have no idea how often the territorial winconditions are played but i guess not very often. So i am unsure if the effort is worth the work.

The easiest solution if the value isn't present is either:

1. Exclude the territorial winconditions from the list, or
2. If a territorial wincondition was chosen: Show a warning that the calculation is may incorrect

We can add the additional code, like you suggested, in a later step.

Just my opinion :-)

Revision history for this message
Toni Förster (stonerl) wrote :

If the lua-code performs fast enough maybe we don't need to implement it in the editor. I'll try to tackle this and keep you informed in the pull request.

Revision history for this message
hessenfarmer (stephan-lutz) wrote :

Hi
with my latest change on my local machine the code is much faster as we don't have to take the immovable fields into account.
see my last comment on the related branch.
 I just need to know how to upload my changes. As new revision or as new branch?

Revision history for this message
Toni Förster (stonerl) wrote :

Add it as a new revision.

Revision history for this message
hessenfarmer (stephan-lutz) wrote :

ok I will push it in an instant

GunChleoc (gunchleoc)
Changed in widelands:
milestone: none → build20-rc1
status: In Progress → Fix Committed
tags: added: wincondition
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
assignee: Toni Förster (stonerl) → nobody
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.