has_workers broken (affects AI when considering upgrade)

Bug #1518223 reported by TiborB
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Low
TiborB

Bug Description

While working on AI, I found that function ProductionSite::has_workers() is badly broken, returning unreliable results.

AI is relying on it when considering if it has experienced worker for upgrade.

Also one important point is that array working_positions = {} in productionsites should start with highest needed worker, because has_workers checks explicitly for first worker (and only first one). Or is there better way how has_workers can say which worker is experienced and must be tested for presence and which can be directly created from working tool in warehouse?

Let me know.

Also I hope reordering in working_positions will not hurt anything. (If there is way how to distinguish experienced workers from novices, this will not be needed, of course)

Related branches

TiborB (tiborb95)
Changed in widelands:
assignee: nobody → TiborB (tiborb95)
Revision history for this message
TiborB (tiborb95) wrote :

worker has is_buildable() flag, so perhaps this can be used to filter out novices from experienced (upgraded) workers. I will test it...

Revision history for this message
GunChleoc (gunchleoc) wrote :

In WorkerDescr, we have a property

becomes_

We could add another property

upgraded_from_

and initialize it with INVALID_INDEX.

This information could then be added to the WorkerDescr in

Tribes::postload()

We could then have a function

WorkerDescr::is_upgraded() {
   return upgraded_from_ != INVALID_INDEX;
}

Would this help?

I am actually not that familiar with the working position functions and produced some bugs there in the one_tribe branch, so there might still be a regression that we have ovelooked.

Revision history for this message
TiborB (tiborb95) wrote :

I have coded something, it seems that is_buildable() is good for this test.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Excellent :)

TiborB (tiborb95)
Changed in widelands:
importance: Undecided → Low
status: New → Fix Committed
GunChleoc (gunchleoc)
Changed in widelands:
milestone: none → build19-rc1
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

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.