mars-sim icon indicating copy to clipboard operation
mars-sim copied to clipboard

The commander should have the authority to appoint roles

Open Musickiller opened this issue 5 years ago • 7 comments

Describe the bug/issue

  • Currently Command mode is a bit empty.

Affected Area

  • Command mode

Expected behaviors

  • One of the commander's responsibilities should be appointing roles to the settlers.

Specifications (please complete the following information):

  • mars-sim build version : v3.1.1 B5285, 64 bit

Additional context

  • Sorry for being so short, if any idea come to my mind, I will make sure to post them here 😺

Musickiller avatar Oct 09 '20 15:10 Musickiller

@Musickiller

One of the commander's responsibilities should be appointing roles to the settlers.

Yes thanks for suggesting that we should give the commander this option.

The use of the role in a settler is still quite under-developed.

Let's discuss more how the role can be used as well in this thread or another thread.

mokun avatar Oct 09 '20 23:10 mokun

Btw, on top of that, we have at some discussions in the past as to how we may model the idea of leadership by the use of the leadership points.

For instance, each time a commander creates an order, it will use up a bit of his leadership point.

This imposes some limits as to how many leadership tasks the commander can do in a prescribed period of time.

Imagine that if the commander is somewhat charismatic, by definition, the subordinates will be more comfortable to be led by him.

Also, his leadership points may have a higher initial value to begin with and the points will be regenerated faster over time.

mokun avatar Oct 09 '20 23:10 mokun

Oh another thing is that I was gonna say that starting in this commit r5381, the commander may assign a task to anyone (not just himself) in his settlement.

For now, we call this a task order assigned by the commander.

mokun avatar Oct 09 '20 23:10 mokun

One of the commander's responsibilities should be appointing roles to the settlers.

@Musickiller ,

It turns out players have already been given the option to change a person's role for a while.

It's available in the person's unit window's Career tab.

You can see the combox box housing a list of role.

Note that if you intentionally a person to take up a leadership role (such as Commander, Sub-Commander or any one of the 7 Chiefs), then the person who previously hold this leadership role will first have to rescind this role.

After that, the designated person will take up this role.

And no worry, this transfer of role is peaceful and no one is fighting over that contested role and is all done by the code automatically :D

Meanwhile, I'll issue a commit to fix some minor things.

In future, each settlement should be able to hold election and each should be able to vote freely in their burgeoning democratic society on Mars.

Having said that, in this case, voters may or may not be well-informed of who they are voting for :D

mokun avatar Oct 12 '20 03:10 mokun

@mokun ,

I'm currently on release 3.1.1, and not sure I will be able to set up the dev environment soon. If you can make a pre-release with fresh features, it would be just great! If not, I'll see what I can do with the dev env.

Musickiller avatar Oct 13 '20 08:10 Musickiller

@Musickiller ,

Yeah. I'm trying to hunt down the starvation/dehydration bug right now and if it's done in a timely manner, I'll release 3.1.2 right after.

For now, is it okay to try out r5390 as it already has lots of things fixed and refined since 3.1.1.

If you spot any bugs or major stuff missing, do you open a ticket and we'll work out a solution.

Appreciate !

mokun avatar Oct 15 '20 05:10 mokun

@Musickiller ,

We actually need to re-consider how the change of the role of a person should be allowed under the Sandbox vs. Command mode.

Let's take a look in terms of the job change. Currently, if players want to change the job of a person, it needs to get the permission from the commander, sub-commander, or one of the chiefs.

For instance, if the player wants Sandy to change her job from being a biologist to a botanist, one can go to the Career tab of Sandy's Person Window and click on the combobox of Job Type to change it.

Once the new job has been picked, the one having the supervisory role will need to execute the ReviewJobReassignment Task in order to approve this change.

So we've modeled it in such a way that it will take a little bit of time for this request to be granted, just like in the real world.

Obviously, during the review process, a few things are being examined in order to determine if that person is good for the new job. (Note that we may discuss further how to improve modeling those criteria.)

https://github.com/mars-sim/mars-sim/blob/05c3756d00a3747917cbbf899756db0d00995269/mars-sim-core/src/main/java/org/mars_sim/msp/core/person/ai/task/ReviewJobReassignment.java#L139-L207

Now going back to the role change, what mechanism should govern how it works in Sandbox vs Command mode ?

That's what we need to conceptualize ahead of time.

mokun avatar Oct 16 '20 16:10 mokun

Is this done?

bevans2000 avatar Mar 28 '23 12:03 bevans2000

Yes. This was done. I just tested it.

But there is an issue with the combobox in displaying the newly picked role before you has yet to confirm with the change in the dialog box.

image

So if I change my mind and choose "No" in the dialog box, it doesn't return to the old role in the combobox. It would display the incorrect role.

image

Only closing the Person Window and reopening it would load the role correctly.

This behavior with the combobox is also true with selecting a new Job.

So it looks like if we fix the Job selection, applying the same fix would correct the Role selection.

mokun avatar Apr 08 '23 17:04 mokun

@bevans2000

Just committed the change.

Now my question is, can we also store the history of role change ?

We recorded the job changes and showed the history in a JTable in TabPanelCareer.

But we don't have one for role change.

However, I don't want to copy what was done in tracking job to what can be done in tracking role.

It's because tracking job has been very elaborated. There's an idea of a job lock that prevents one's job from being changed constantly.

There's also JobHistory and JobAssignment to assist with the change of a job.

Do you mind taking a quick look at how we may handle role change more efficiently ?

mokun avatar Apr 08 '23 18:04 mokun

No problem. Sounds like we need a Generics class that can store a changing value over time. We could apply it to Job & Role as a starter.

bevans2000 avatar Apr 08 '23 19:04 bevans2000

@bevans2000

Currently, there's a small difference between how the job combobox behaves versus how the role combobox behaves. This leads me to ask the following questions :

Q1: Should we pause the simulation when asking if player wants to change a person's job/role ?

By default, the update() method in TabPanelCareer will continue to call checkRoleChange() and checkJobReassignment() - which will return the job back to what it's supposed to be in the combobox, even though player may still be in the process of pondering about what to choose from (yes, no or cancel) in the JOptionPane.

Q2 : How would you detect the pop up of JOptionPane in such a way that we may pause the simulation ? Should we attempt to tweak the modality ?

mokun avatar Apr 09 '23 22:04 mokun

No problem. Sounds like we need a Generics class that can store a changing value over time. We could apply it to Job & Role as a starter.

So after a quick look I think what we need is a generic way to model values that change over time. It is very similar to the DataLogger concept we already have. So we would just update the value and the history is automatically recorded. This concept is already provided by the MSolDataLogger but in this implementation data is held in a Sol orientated representation which is expensive for slowly changing values. Nevertheless, I think we can do something to reuse/improve what we have allowing us to hold a simple List of value changes; this would be applicable to lots of other cases as well, e.g. VehicleLog & ActivityLog. The question is should we hold these in a flat list representation and extract entries for a specific sol when needed. We only need the sol representations when the log is shown in the UI which is a very small fraction of the total number of "logs" entries we hold. Hence at the moment we are storing values optimised for the UI at the expensive of more memory consumption. The problem I see is it is related to #650 as we don't model an instance in Mars time as a fixed immutable value. Do you want to add this to 3.6.0 ?

bevans2000 avatar Apr 11 '23 15:04 bevans2000

MissionLog can also use the new pattern

bevans2000 avatar Apr 13 '23 18:04 bevans2000