The International Simutrans Forum

 

Author Topic: New GUI feature showing commuting, visiting and staffing levels on the minimap  (Read 826 times)

0 Members and 1 Guest are viewing this topic.

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
I tried to make such a patch by improvisation.



my Github branch

It can display "Commuting success  percentage", "Visiting success  percentage", "staffing percentage" on the mini map.
The text of label and tooltip will need to be changed.

This will help you to see if economic activity in the game is going well.
I make it so red that there is a problem. For example, red is displayed when the staff is 0%.

At first glance, since most of the employment is filled up, it seems that there are many people who can not find the work place.

Happy holidays. (´・ω・`)
« Last Edit: December 27, 2018, 09:37:42 AM by Ranran »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
This is very interesting, thank you: a most useful feature.

One change that I think would be helpful to improve the signal to noise ratio for the "commuting" and "visiting" displays is to average the current and previous year's data where the latter are available. This is because, especially early in the year, the current year's data might be drawn from a very small sample size of attempts and thus be somewhat unreliable. I have noticed a number of instances where there was a 100% commuting success rate in the previous year and a 0% success rate in the current year despite nothing having changed between the two years in transport terms.

Another thing that I notice in testing is that some industries refuse to accept staff because they are unsupplied. These industries will need to be shown differently (perhaps in purple or very dark red) to make clear to the player that they are unstaffed not because staff cannot reach them but because they are not accepting staff at present.
Edit: I have noticed a bug with this feature: multi-tile attractions will not show the correct staffing data: they will show all red apart from one corner (I presume the base tile), which will show the correct colour. I have not tested multi-tile city buildings, as the pakset does not have any yet, but the same may well apply to those.
« Last Edit: December 26, 2018, 02:56:33 PM by jamespetts »

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
Thank you for your advice, that is a very helpful.
"Commuting" and "Visiting" have been changed to refer to the average values. It was easy because a valid function already existed.
The factory which is not in operation is now displayed in dark purple.
Also corresponded to multi-tile buildings.
Texts still need to be considered.
Please check it again.

EDIT:
I'm sorry, I was forgotten to make commuting" and "visiting"  corresponded to multi-tile buildings.
I made a dummy multi-tile RES building and testing.
And now committed it to the my github branch.
« Last Edit: December 27, 2018, 02:08:03 PM by Ranran »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Thank you for this: that is an improvement. However, I notice a new bug introduced into this version: for the commuting and visiting displays, there seem to be no colours displayed between green and red (red being displayed at 0%, green at all values > 0%); this is an issue during the first year of operation, so this might be a bug in the averaging algorithm for cases in which there are no data for the previous year.

In relation to inactive industries, may I suggest disapplying this system to primary industries (i.e. industries which produce but do not consume)? These industries always demand staff, and so, for staffing purposes, they are never inactive. The multi-tile fix seems to be working well, however.

Edit: As to the text, incidentally, the labels seem to be good, but the tooltips would be better as:
Commuting: Show the success rate for commuting passengers
Visiting: Show the success rate for visiting passengers
Staffing: Show the staff shortage rate
« Last Edit: December 27, 2018, 03:24:29 PM by jamespetts »

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
Thank you for your confirmation.
The function for averaging the probabilities was not working properly. It seems that the problem did not occur because it is not used elsewhere. Therefore I modified this function.
It was my shortage of confirmation - my apology. :-[

I have updated my github branch.

I will post to another thread about fixes which is out of main theme of this thread.

And I have a question, is there a value for making mini-map like coloring RES/IND/COM?  :idea:  (for future a full reworking of the town growth system)
I think I can make it.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Thank you for this. I have split this topic from the topic about recalibrating town buildings, as the latter was more about pakset calibration, whereas this is an entirely new feature and belongs in the subforum dealing with development of the code.

The bug fix appears to work - thank you for doing this, and apologies for having written in the error in the first place.

In relation to your idea for a map showing colouring for different types of buildings - this is a most interesting idea. I think that it should be more sophisticated than simply residential/commercial/industrial, however, as that distinction does not fit well with the way in which buildings are used in Simutrans-Extended (is an "industry" that is a shop commercial or industrial?); we also need to leave room for the possibility of having in future buildings that have both residential and non-residential uses as I am hoping to incorporate this into the future work on town growth. Perhaps this discussion should go into a separate thread?

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
Quote
I think that it should be more sophisticated than simply residential/commercial/industrial, however, as that distinction does not fit well with the way in which buildings are used in Simutrans-Extended (is an "industry" that is a shop commercial or industrial?);
I completely agree with that. Since commercial and industrial buildings have overlapping parts with factory, also depot, station and signalbox etc. have employment, color grouping may be difficult with one map, so please forget this topic once. :redx:


Quote
we also need to leave room for the possibility of having in future buildings that have both residential and non-residential uses as I am hoping to incorporate this into the future work on town growth.
Perhaps this discussion should go into a separate thread?
I know that there is such a plan reading this thread about "Town growth based on local transport".
It is very interesting. :-*
"Commuting" and "Staffing" are paired, and I was thinking about whether I can add a pair of "Visiting".
From the current specification I can make mapping the potential demand of the visitor, or the arrival record of the visitor in the last two years.
Other idea is such as mail delivery success rate also written in that thread.
I think that these will depend on future plans, so discussion may be necessary.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Yes, the town growth is an important and significant project, but I am some way off even being able to start it at present given the number of critical bugs outstanding and a whole other project still in the fairly early stages to complete before that.

However, the numbers of visitors that buildings receive can be mapped in a similar way to the staffing display: you can create a ratio of visitors compared to visitor demand, or you can develop a scale using absolute numbers, although it is hard to see how the latter could be calibrated, so I suspect that the former would be preferable.

It would certainly be worthwhile mapping mail success rates, too, although those are not currently recorded. Because mail is fully symmetrical, unlike passengers, the simplest way of dealing with mail success rates is simply to have a single figure representing the proportion of mail that a building attempts to send that successfully gets to its destination. In principle, this could be added independently of and prior to the town growth work using the same sort of algorithm as for passengers, although I am not likely to have time to do this myself for quite a while yet.

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
I tried to add mail delivery record to the building. Repository
I think that it is working, but I think that there is a problem with save compatibility.
Old save can not be load, but demo.sve can load. Are there any other parts that I must change?

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Thank you for working on that. Two things: first of all, the saved game revision: you need to increment EX_SAVE_MINOR not EX_VERSION_MINOR: the latter is only used for display to the player, whereas the former is used for saved game versioning.

As to the mechanism, I think that this needs some rethinking. Currently, your patch records, for each building, the amount of mail that that building has sent and the amount of mail that that building has received: but this does not tell us anything about the mail success rate, since there is no necessary symmetry between the amount of mail that a building will send and receive even assuming perfect mail transport throughout the map.

What we need to do is, instead of recording how much mail has been received by a building, which is not a very useful datum, record how much mail sent by each building has been successfully delivered, in much the same way as is done for passengers arriving successfully at their destinations. That way, we can keep a track of the proportion of mail sent by a building that is delivered successfully and get an idea of the success rate for mail transport from a building.

With those amendments, however, this will be a very worthwhile addition: thank you very much for working on this.

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
Now it can successfully load the old save. Thank you for your advice. :)

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
I fixed the mechanism and calculated the delivery success rate of mail and made it possible to confirm with the mini map.
However, sometimes the success rate may exceed 100% so something may be wrong. (´・ω・`)
Could you check this out? (As usual label and help text also)

This bug (city attraction do not inherit the last year record) also occur to mail records, but I have no idea why it's only city attractions... ???
« Last Edit: January 06, 2019, 04:02:36 PM by Ranran »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Thank you for this.

In terms of the variable names, "mail_generate" should be "mail_generated". Also, is there a reason that we need both mail_delivery_succeeded_last_year and mail_delivery_success_percent_last_year? Surely, one would either collapse both into a single percentage figure for last year, or keep the separate records of how much mail had been generated and how much had successfully been sent and calculate the percentage on the fly; or was there a specific reason for this arrangement?

A more fundamental problem is here:

Code: [Select]
else if (ware.is_mail())
{
- gb_dest->add_mail_received(ware.menge);
+ gb_dest->add_mail_delivery_succeeded(ware.menge);

gb_dest is a pointer to the destination building, which means that you are adding the success of delivered mail to the building to which it is delivered, rather than to the building which sent it, which, I infer, is why you are sometimes getting success rates > 100%. May I ask what was intended with this; did you imagine that this was recording the successful delivery at the origin building, or does this not need to be present at all?

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
Thank you for the very precise identification. That is my misunderstanding, my apology. Now fixed.

was there a specific reason for this arrangement?
This is because visitors and commuters records are displaying percentages on the RES info window but others are displaying absolute quantities.
And the absolute amount is hard to understand in the percentage mapping, so I thought that it could be used to mapping the amount of mail shipment.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Thank you for this: I am now testing it. I notice that the behaviour in the UI of the mail success percentage is different to the commuting/visiting passenger percentage: unlike with the passengers, nothing is displayed for the current year if there have been no attempts to send mail. May I suggest either removing the display of visiting and commuting passengers when there are no data for these or making the mail success percentage even when there are no data?

Also, may I ask why attractions/industries have a different text string for mail delivery success than city buildings? The mail delivery mechanism is not different for these buildings (unlike for passengers, whose journey always ultimately starts at a residential building, mail can be initiated from any building), so it does not make sense to display this differently.

Other than that, however, this is very useful - thank you.

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
Thank you for testing. I made a change based on your opinion.
In the case of "no data" it is displayed in dark slate blue. Is this color all right? Are there other good colors?
Aside from the start of the game, this color will almost not be seen except for town building updates.


About "Staffing" case, I couldn't fix that displayed color which after the game start.
get_staffing_level_percentage() returns 100 (In other words, check_remaining_available_jobs() returns 0) even immediately after starting the game.
Buildings with all employment seem to be filled with worker like this. Therefore, it is displayed with green.

Is this a correct specification?

Quote
Also, may I ask why attractions/industries have a different text string for mail delivery success than city buildings?
To be honest with this, that is just temporary assembly... (´・ω・`)
This window already kind a chaos... but adding a mail record further increases two more rows.
I was looking for something good way and I know that it is troublesome to get out of such like a notepad.
I just placed a form that would fit the current text on the same window. In RES window show only the percentage,  in others show the absolute number, so there is no special reason for that format.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Thank you for that.

Yes, it is correct that, when a map is generated, all jobs are filled: this is intentional to prevent deadlocks and difficult behaviour at the start of the game, so there is no problem with this showing as green in the staffing view.

However, what I was asking about above was the text display when there are no data, not the graphical display: apologies for not being clear. In the building information window, the commuting/visiting success percentages are shown even when there are no data, but the mail success percentage is shown even when there are data. Would you be able to modify this so that they are both consistent? I should be very grateful.

Thank you again for your work on this.

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
That's right. I am sorry for misunderstanding. (´・ω・`)
I made it always shows the mail record if building has mail demand, and it made consistency with factory display.

And I found that in factory dialog cause such text conflict when shifting from game starting year to next year.


I made a quick fix to put empty lines when there are no previous year's data. Another way to solve this is to recalculate the position of the chart and resize it, but I did not know how to do it. Could you please fix if that way is preferred?

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Splendid, thank you: I have now incorporated this. I should be very grateful if you could now prepare the .dat file for the translation texts.

As to the industry dialogue, it would take me quite a while to remember how to adjust this, so we will leave it as it is for now.

Thank you very much for your work on this: this is most useful.

Offline Ranran jp

  • *
  • Posts: 293
  • Languages: ja
Yes, I attach it to this post.
If my English is inaccurate, please modify it along with the code.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18210
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Splendid, thank you for that. Now uploaded.