mars-sim / mars-sim

Mars Simulation Project Official Codebase
https://mars-sim.com
GNU General Public License v3.0
101 stars 36 forks source link

Design Idea: Command Mode #188

Closed mokun closed 2 years ago

mokun commented 5 years ago

The idea of having a Commander Mode in mars-sim was recently proposed in this thread.

In the past, mars-sim runs in Sandbox Mode and player has the god-like power to do certain things for all the settlements in a simulation.

Under Commander Mode, however, the player is supposed to be limited to making decisions on behalf of one settlement only.

Q1 : So, how should this Commander Mode be implemented in mars-sim in real terms?

While there are turn-based strategy games out there (such as Civilizations), mars-sim has always been a real-time strategy simulation.

mars-sim game loop was designed from the ground up to run like a clock. Each settler needs time to perform/complete a task or a mission. Each task and mission are time-dependent and are measured against this clock.

Unless the player pauses the simulation clock, this clock gives reference to the passage of time that the settlers would experience on Mars in a compressed manner.

Say, if the time ratio is 256x, we essentially set the simulation clock to run at 256 times faster than the normal passage of time that we human beings would experience.

Q2 : how should the Commander Mode modify this time-dependent design to allow for the end of a turn for the player ?

mokun commented 5 years ago

I'm thinking of implementing a production point and leadership point system.

Say if a player exhaust all the production points, he cannot do anything but wait and rest and let the points regenerate...

Similarly, if a player decides to do something but mistakes and fail to achieve certain objectives, he would exhaust the leadership points and cannot make more directives or decision until the confidence of other settlers are restored, etc.

If he does well in interpersonal relationship is in good terms with his team, it would also earn him some leadership points.

This allows for more simulation complexity and less god-like micromanagement than in Civilization.

Urwumpe commented 5 years ago

Well, my idea would have been going along rogue-like conventions: Without action of the player, the game pauses. In the worst case, the game would stop every few seconds, but for certain longer lasting actions like sleeping, driving or training, having a few millisols of time passing would be possible.

mokun commented 5 years ago

Yes I do think pausing the game will end up adding more interactivity in Commander Mode. It will probably be the next best move.

The question is, what options do we envision that the commander will have at his disposal ?

Urwumpe commented 5 years ago

Well... I would say, the options should be tasks or better: Task generators, as many tasks require parameters to be fully created. Some tasks might even better be only available in commander mode, since they could be too fine grained in other modes.

UI-wise, I would say the recommendation should be leaving the decisions how the tasks are arranged and presented to be configured by the player and just have a default configuration in the UI clients.

For headless: I am not sure if parsing english language would work out there.

mokun commented 5 years ago

Task generators, as many tasks require parameters to be fully created. Some tasks might even better be only available in commander mode, since they could be too fine grained in other modes.

I'm thinking for building an UI for the commander to recommend and/or allocate specific Tasks and Missions for the crew to perform the next few days or the next work week.

To do so, the player as the commander will need to do some research on his team mates and decide what tasks to allocate.

In future, we may code it in such a way that the commander doesn't have to micro-manage and may simply rely on his chiefs to do the work.

mokun commented 5 years ago

UI-wise, I would say the recommendation should be leaving the decisions how the tasks are arranged and presented to be configured by the player and just have a default configuration in the UI clients.

So what minimum amount of coding do we still need to do ?

Do you mean that you want to have the flexibility from the beginning for the player to configure how tasks appear ? Can you give me an hypothetical example ?

Urwumpe commented 5 years ago

So what minimum amount of coding do we still need to do ?

Well - we would need task generators or builders for the required tasks. Since we have many tasks, that would be a lot of effort. But the alternatives would not be much better there.

Also, we would need some basic UI for those.

Do you mean that you want to have the flexibility from the beginning for the player to configure how tasks appear ? Can you give me an hypothetical example ?

For example Player A prefers a exploration gameplay - so he configures the UI that the tasks for creating exploration missions or analyzing collected samples are more easily accessible than others and maybe also creates a template task generator that has most parameters for some tasks already preset.

Player B prefers station building, so he configures his UI to favor tasks that handle production.

Player C prefers science, so he puts emphasis on science-related tasks.

Urwumpe commented 5 years ago

To do so, the player as the commander will need to do some research on his team mates and decide what tasks to allocate.

One common idea I had used on my rogue-like gaming projects had been using an "associative encyclopedia" view, that allows accessing information learned. This could for example be used for accessing information about the team mates or the abilities of buildings, etc.

mokun commented 5 years ago

configures his UI to favor tasks that handle production.

So we're going to create an UI that incorporate flexibility for players to configure where and which buttons/combobox, etc. will show up by simple dragging and dropping in various UI elements onto some prefined area onto the screen, right ?

There may be templates that we can develop to serve as examples on what it can look like for various mission emphasis.

mokun commented 5 years ago

You mentioned about player's simulation preference/emphasis.

It strikes on me that a commander's career should have some sort of progression associated with it.

Say, after he runs many operations/missions successfully, he should be qualified for a promotion to do something else and get to have other responsibilities on his plate, assuming that we can make the Martian world dynamic and changing and growing...

Urwumpe commented 5 years ago

It strikes on me that a commander's career should have some sort of progression associated with it.

Say, after he runs many operations/missions successfully, he should be qualified for a promotion to do something else and get to have other responsibilities on his plate, assuming that we can make the Martian world dynamic and changing and growing...

Well, since we are currently focussing on starting as the commander of a settlement already, any kind of progress in hierarchy could only be moving to bigger settlements or having a next tour of duty.

Maybe there should be personal goals to achieve? Like selecting on creation of the game, which motivations made the player character go to Mars?

Or we relax the initial idea and make becoming commander of a settlement one possible goal?

Urwumpe commented 5 years ago

configures his UI to favor tasks that handle production.

So we're going to create an UI that incorporate flexibility for players to configure where and which buttons/combobox, etc. will show up by simple dragging and dropping in various UI elements onto some prefined area onto the screen, right ?

Yes, I think that makes most sense. Even if we use a mostly fixed layout and just change the generators behind the buttons. Also, I don't want to say it is the single final UI. Keep things open for new ideas. There should be just one UI from the core team as reference UI.

There may be templates that we can develop to serve as examples on what it can look like for various mission emphasis.

Yes, that sounds like a good idea - maybe some players could have better templates later.

mokun commented 5 years ago

I just found a simpler way of pausing as we are about to implement how the commander mode should work.

The JDialog has this behavior that can block other things from running and let the player do only one thing at a time but it's too limited for our use.

So, we have been using ModalInternalFrame to give the ToolWindow that extends JInternalFrame class to provide this modal behavior for our use.

e.g. when the player open the Mission Tool, the simulation would be suspended.

However, if we use JavaFX, there's no such class that will work in the JavaFX thread until now.

This pure java implementation of coroutine should come in handy for us to achieve pausing easily, instead of trying to stop the gameloop by gaining synchronized access to it in order to alter the state of a valuable that can break out of the while loop, etc.

With coroutine, we don't have to worry about messing up the timing aspect of the simulation, since everything would be paused.

When unpaused, things will simply resume from the very state before the pause.

This is great news since I was told that using coroutine to suspend an app would use up virtually ZERO cpu resource.

This removes one big hindrance for moving into mobile platforms (Android, iOS, etc) as the battery would not be wasted.

mokun commented 5 years ago

Maybe there should be personal goals to achieve? Like selecting on creation of the game, which motivations made the player character go to Mars?

if we give the player the immersion experience of being a commander, why not also give them the experience of being a scientist? Say, being a biologist, or any other Subject Matter Expert (SME) ?

Naturally, each career would have its own goal.

any kind of progress in hierarchy could only be moving to bigger settlements or having a next tour of duty.

To enable a player to have the next tour of duty, we will need to create a bigger world.

May be not in near future, but we can certainly make the world of mars-sim grow bigger by adding a different layer of simulation.

What if we will also do a macroscopic simulation of the Martian society 50 or a hundred years after the first human landing ?

I'll open a new thread to discuss further about this career immersion/progression thing.

Urwumpe commented 5 years ago

if we give the player the immersion experience of being a commander, why not also give them the experience of being a scientist? Say, being a biologist, or any other Subject Matter Expert (SME) ?

Naturally, each career would have its own goal.

Yes, but maybe there should also personal goals or motivations additionally to those careers to add a bit more flavour. Like a Botanist with an interest in cooking, who plans to open the first restaurant on Mars.

What if we will also do a macroscopic simulation of the Martian society 50 or a hundred years after the first human landing ?

So, in summary: Kim Stanley Robinsons "Red Mars" as game. ;-)

mokun commented 5 years ago

Kim Stanley Robinsons "Red Mars" as game. ;-)

Yes it will be wonderful to build a world-level simulation in mars-sim one day !

But for now, do you think by any chance we can incorporate the city-level simulation into mars-sim in some ways ?

Urwumpe commented 5 years ago

Depends on what you would call a city-level simulation. I would say four settlements with 1000 settlers should be possible right now with an old i7 (=my 7 year old dev rig). For simulating a Mars with more than 10000 settlers, I think we would need cluster/cloud support for the simulation backend.

In commander mode, the delay for computation would be even less dramatic, since the gameplay would be generally slower than usual.

mokun commented 5 years ago

Depends on what you would call a city-level simulation.

In the city/world-level simulation, I envision we are going beyond simulating the daily lives of the settlers to simulating, say, 50+ settlements/towns/weather stations/unique structures over the surface of Mars and whatever in orbit around Mars. So it will be the simulation of the intricate relationships and socio-political-economical forces and dynamics between these colonies.

We can also simulate companies beginning to hire people to open up the new frontiers and environmental impact associated with what they do.

In essence, we no longer need to know the detail of what each settler does but we still simulate collectively how many politicians vs. scientists vs. engineers and the numbers and types of projects they are doing in contributing to developing the new frontier.

The player will initially be the mayor of one settlement but can be promoted to become a district superintendent to set social/economic/governmental policies over those settlements under his jurisdiction.

So this is like if the player is pursuing the political track in his career, then after he has completed certain goals and won enough votes, he's promoted from handling one settlement to being in charge of a number of settlements/mining town at the city-world level of simulation.

I recall an old game called "Spore" and the game dynamics changes at each level. May we do something similar with career progression ?

Can we expand mars-sim to incorporate this city/world level simulation ?

Urwumpe commented 5 years ago

Well then, it is mostly about being able to partition the simulation into smaller chunks to be calculated by separate processors with minimal communication. The less "hive-mind" the settlers use (e.g. having global manager classes), the easier it is, also if we honor the CAP theorem, we could maybe drop the consistency of data from distant locations a bit and pretty much simulate "islands" on Mars. For example, information about other settlements could arrive later at a settlement simulation partition, being a bit inconsistent that way, but increase performance a lot.

Urwumpe commented 5 years ago

Some feedback on testing the commander mode right now:

  1. 5 millisols should really be the minimum - it feels very disruptive, I spend pretty much most of the time hitting Resume. I would prefer longer periods. Maybe even rather waiting for the next significant event of the commander (Task done, Asked for mission assignment, End of Sol, etc)
  2. The commander tool should have a button to open the unit window of the commander directly.
  3. For implementing the logic of the commander mode, what about making use of the narrator package and provide two implementations of a to-be-defined Director interface. The standard sandbox director would do nothing or just avoid interrupting the simulation. The commander mode director would wait on decisions by the player via the commander tool. This way we can have the logic for the commander mode mostly in one place and not spread over multiple modules and packages.
mokun commented 5 years ago

5 millisols should really be the minimum - it feels very disruptive, I spend pretty much most of the time hitting Resume.

Yes I felt the same.

Maybe even rather waiting for the next significant event of the commander (Task done, Asked for mission assignment, End of Sol, etc)

May be we can create a combo box and let user choose what to wait for?!

Urwumpe commented 5 years ago

May be we can create a combo box and let user choose what to wait for?!

Sure, where would you place it? In the commander tool or in the time tool?

mokun commented 5 years ago

where would you place it? In the commander tool or in the time tool?

I'll add a tab in the new Commander Dashboard for players to adjust the interval between each pause.

mokun commented 5 years ago

@Urwumpe and @shirishag75

For the time being, I set the pausing interval from 5 to 500 millisols for just testing purpose.

The time span of 5 millisols is too short because, at this point, there isn't much for the player to manually set up anything in the Commander Dashboard for the commander to perform.

Later I'll add a spinner bar or a combo box for the player to change the time interval.

For now, setting it to 500 millisols is not that bad.

Question: what would be the top 3 things you can think of to be included in the Commander Dashboard ?

Urwumpe commented 5 years ago

Well, first of all, I think there should be some way for every player to adapt the dashboard to his tastes.

Next, I assume that a "Mail Inbox" or "Social Network" of Mars would exist in MSP anyway in both commander or sandbox mode and would not have to be implemented into the dashboard (In sandbox for having a BOFH view and control of the settlers.). I focus on just what would be needed exclusively for commander mode.

My Top Three then:

  1. A list of current tasks (decisions) for the commander - either assigned to him by his function or by assuming responsibility.
  2. A "character sheet" summary of the commander himself - how does our commander feel today? More condensed than the full Unit Window, but enough quickly readable information to not become suicidal (Sleep and food are not optional)
  3. A matrix or row of programmable buttons for having shortcuts would make sense in a dashboard. Like, quickly bringing a special tab in the unit window of the settlement into the foreground. Or selecting a common task as next task for the commander.

Not sure if I would prefer a fixed top level layout for the dashboard or not... I think limiting freedom a bit could make it easier to use (Like just being able to choose what is displayed left, center, right and on top, have a fixed element on the bottom).

mokun commented 5 years ago

Okay. Let's discuss your top 3 one by one.

A list of current tasks (decisions) for the commander - either assigned to him by his function or by assuming responsibility.

You mentioned about tasks and here is the status.

Currently, it show a list of all available tasks. However, some of them can't be executed MANUALLY.

e.g. "Assist Scientific Study" is impossible if no one has initiated a scientific study yet or if the commander doesn't have any medical skill and the only research being conducted is Medicine.

We will need to group them in different categories and use checkbox to apply filters of some sort.

Q1 : what will these categories be ?

I can think of only 2 tasks below that are commander-specific.

I have wanted to use "MeetTogether" for rallying one or more settlers together or even for requesting settlers to come and attend a conference meeting, etc.

We could add "Negotiate Trade" to the commander's bucket list. It was carried out by traders but the commander of the bartering settlement should/could get involved.

Q2: what are the major/critical tasks you think we should add at this moment ?

mokun commented 5 years ago

@Urwumpe ,

Work shift is another aspect we'll need to consider when designing the task queue.

As you know, right now, for a 4-person or less settlement, it will have a 500 millisols (~12-hour) work shift. We call it Shift A and B.

For settlements with 5+ settlers, it will have a 333 millisols (~8-hour) work shift. We call it Shift X, Y and Z.

Does it make more sense to limit everyone to do a work-related task during his work shift and to do a non-work related task during his off-duty hours ?

For now, having this artificial division of tasks reduce the cpu usage.

Urwumpe commented 5 years ago

I think this division also makes sense for making it possible to make settlers balance conflicting needs. Work-Life-Balance maybe, but the best interests of the Mars Base are not always the best interests of the settler. During work, the needs of the base dominate, during off-duty, the personal needs dominate.

In theory for example, somebody could be working on two different scientific studies - one big work related with the available equipment of the base, another in his free time just for self realization.

Like: At work, the settler has to be what the mars colony wants him to be. Off-duty, the settler can be who he wants to be (maybe with some influence by the personality model, like some characters trying more to fit into the population, making the needs of others their own needs.)

Urwumpe commented 5 years ago

Also, about Q1: I would not limit those categories now. Especially since this can still change a lot while the commander mode is developed.

Q2: Right now, I see primarily organisational tasks missing there. Assigning people to functions for example. Declaring emergency would be a good start as well.

For a more generic approach, I would maybe add a "use application" there for allowing player and NPCs to interact with software tools for more complex tasks. We would then need a human interface model for the PC and a flexible DSL for the NPCs, which is used by the NPC task that embedds the "use application" task.

mokun commented 5 years ago

We would then need a human interface model for the PC and a flexible DSL for the NPCs, which is used by the NPC task that embedds the "use application" task.

Yes. It's cumbersome to create a new tasks right now. And we already have 50+ class that extend the MetaTask and ~55+ class that extend the Task.

This would be fun to create a flexible DSL for executing tasks, instead of hard-coding each detail step and having a lot of boilerplate codes.

Let's open a new thread and discuss specifically how we may do it.

shirishag75 commented 5 years ago

+1 to the above. Right now it is cumbersome to do tasks. Btw I don't remember if mars-sim is python3-compatible or not. Debian is removing python2 altogether in the near future, so mars-sim would have to be only python3 compatible.

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931659 for more info.

Edit : I know we are dependant on java 11 or java 12 as and when it comes, but dunno if there are any python stuff in it or not. If it is, then the above is for that.

Urwumpe commented 5 years ago

Not that I know that some python exists. Should we ever include a scripting language, I would vote against Python. While it has some advantages, refactoring Python is a terrible job.

shirishag75 commented 5 years ago

do agree with the above.

mokun commented 5 years ago

Nay we don't use python in mars-sim.

So does debian support openjfx 11 now ?

shirishag75 commented 5 years ago

I dunno if it supports or not but yeah, we do have openjfx 11 now.

$ apt-cache policy libopenjfx-java 
libopenjfx-java:
  Installed: 11.0.2+1-1
  Candidate: 11.0.2+1-1
  Version table:
 *** 11.0.2+1-1 900
        900 http://cdn-fastly.deb.debian.org/debian testing/main amd64 Packages
        100 http://cdn-fastly.deb.debian.org/debian unstable/main amd64 Packages
        100 /var/lib/dpkg/status

As can be seen it is installed See http://paste.debian.net/1095932/ for more details as to how it is set up exactly.

mokun commented 4 years ago

Just added a Policy tab yesterday.

As you can see inside, there are only 2 options regarding Trading Mission for now.

image