yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.13k stars 1.52k forks source link

Feature request: Disable constructions #9980

Closed hackedpassword closed 8 months ago

hackedpassword commented 11 months ago

I tire of fighting with my own cities not to build certain things, and sometimes they sneak it through anyway. Then for say uranium for example, hey where's that resource? It was here a minute ago? Someone prob built a reactor now I have to audit 15 cities and find the perpetrator. Can we denounce our own cities?? Let's do that.

So the proposed feature here is to long press the + (plus) on a construction, any unit, building, wonder, other, whatever. That item is then sent to another section like "Disabled", looking like any other section in construction, still with a plus like any other. If the player hits the plus on the disabled item, pops it back where it should be. Meanwhile, anything in the disabled section is not factored when a city is choosing constructions on its own.

Screenshot_20230827_105856

Skekdog commented 11 months ago

You can disable auto city construction in settings

hackedpassword commented 11 months ago

I don't want to disable construction, I want to disable certain construction.

SomeTroglodyte commented 11 months ago

Can we denounce our own cities

No but you can raze them. Should give the same satisfaction. You could also nuke them. If that's too slow or not brutal enough, there's a "raze-all", usually found as "shutdown" or "apps-uninstall" or somesuch.

hackedpassword commented 11 months ago

Is that a hint? Ouch!

SomeTroglodyte commented 11 months ago

😈 just perpetrating your joke again

But - a "misfits" list would need to be persisted otherwise people would complain faster than light, and that's not quite trivial. Raises questions - per game per civ or per settings or (per game: clean. you want: global. possible conflict: mods)... One list or two to safely distinguish unit & building of same name...

SomeTroglodyte commented 11 months ago

If someone wants to try/test and can run from source: branch ConstructionBlackList - or as jar - to find the feature use right-click.

Shows the complications nicely:

hackedpassword commented 11 months ago

😈 just perpetrating your joke again

LOL you know I got you. I'll check that jar out later maybe tonight at best, pressing priorities this day.

Implementation sounds tricky. I'm guessing then that the lists shown on the construction screen are generated with some inferred data structure magic rather than say a stored list of available construction. Makes sense, consequentially making more sense why a separate blacklist would have to be held.

Is there a structure for save games, some local per installation config that can associate data to individual saves? Hmm that wouldn't be optimal either when uploading saves.

I feel this idea may be proven technically impractical seeing the issues involved @SomeTroglodyte.

hackedpassword commented 11 months ago

My review of your .jar - a new in-city menu that adds refreshing functionality!

  1. I love it. This is a feature that belongs, flows naturally and provides expected gameplay UX.
  2. Works as advertised* - I'm tempted to migrate to this .jar for regular games.
  3. '*' As implemented, anything added to the disabled menu is global for all cities. That's a frustration.
  4. Disabling all buildings and wonders leaving units enabled will ignore units for auto-build next turn.
  5. See # 1. Being able to bench a build is way better than I first imagined. It's good.

I hope others give it a try! I'm certain not everyone will feel the same but since you have to long-press/right-click the menu, there's no UI change otherwise.

SomeTroglodyte commented 11 months ago

That's a frustration

Why? I thought that was the point?

4.

Oh, worth investigating.

hackedpassword commented 11 months ago

That defeats the purpose - you're trying to prevent your other cities from consuming resources another needs, or, steer a city to a construction goal instead of it auto picking a poor build. Lots more reasons for individual city control.

Really nice work for this demo test! =)

SomeTroglodyte commented 11 months ago
  1. Disabling all buildings and wonders leaving units enabled will ignore units for auto-build next turn.

Can't repro. I start a small vanilla game, disable the Monument, enable autochooseproduction, and a Worker is queued as expected. How exactly? Can you demo with a save and the GameSettings.json?

That defeats the purpose - you're trying to prevent your other cities from consuming resources another needs, or, steer a city to a construction goal instead of it auto picking a poor build. Lots more reasons for individual city control.

Then I don't get it, not entirely. Prevent other cities from using up Uranium -> I disable Nuclear Plants, and queue it manually in the city I want it in. Or, disable Barracks and build it manually in the one city I got all other XP/Promotion giving buildings in. AI will follow up with Armory automatically. Sounds simple and easy. "goals" sounds more like implementing Queue templates - like "save this Queue as template" - "apply template" - "choose default city queue template"... Old idea and not extremely difficult, but a long chore. Hampered by the current Queue limitations. I had a queue code well over a year ago that was intelligent - queue a University after a Library, prevent reordering a dependent above a dependency, count max allowed correctly, and some more, but that went down some drain somewhere. I don't see per-city blacklists as very useful as you might spend a lot of time getting what you want, and might be quicker by disabling auto entirely and queueing everything yourself. Which that original menu (PR #9961) I used as UI helps with...

hackedpassword commented 11 months ago

GameSettings.json.txt

Github doesn't accept json files? lol!

China - 56 turns.txt

Save game. In this state, Bejing produces nothing and maintains producing nothing.

Here's another good one - try removing "Nothing" from the active queue "in all cities". Unciv will be very upset about this.

I added "nothing" to the queue of all cities. Worked... for a little while then Unciv lost coherency and crashed: D:\Dev\Unciv dev>java -jar Unciv-ConstructionBlacklist.jar [LWJGL] [ThreadLocalUtil] Unsupported JNI version detected, this may result in a crash. Please inform LWJGL developers. Exception in thread "main" java.lang.IndexOutOfBoundsException: index can't be >= size: 6 >= 4 at com.badlogic.gdx.utils.Array.get(Array.java:155) at com.unciv.ui.screens.cityscreen.CityConstructionsTable.ensureQueueEntryVisible(CityConstructionsTable.kt:795) at com.unciv.ui.screens.cityscreen.CityConstructionsTable.getQueueEntry$selectQueueEntry(CityConstructionsTable.kt:357) at com.unciv.ui.screens.cityscreen.CityConstructionsTable.access$getQueueEntry$selectQueueEntry(CityConstructionsTable.kt:71) at com.unciv.ui.screens.cityscreen.CityConstructionsTable$getQueueEntry$2.invoke(CityConstructionsTable.kt:362) at com.unciv.ui.screens.cityscreen.CityConstructionsTable$getQueueEntry$2.invoke(CityConstructionsTable.kt:362) at com.unciv.ui.components.input.ActivationActionMap.activate(ActivationActionMap.kt:56) at com.unciv.ui.components.input.ActorAttachments.activate(ActorAttachments.kt:42) at com.unciv.ui.components.input.ActivationExtensionsKt.activate(ActivationExtensions.kt:17) at com.unciv.ui.components.input.ActivationListener.longPress(ActivationListener.kt:20) at com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener$1.longPress(ActorGestureListener.java:58) at com.badlogic.gdx.input.GestureDetector$1.run(GestureDetector.java:58) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:208) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.(Lwjgl3Application.java:166) at com.unciv.app.desktop.DesktopLauncher.main(DesktopLauncher.kt:82)

The general problem with manual queuing comes when your empire is vast and it is no longer practical to micromanage. That's why I'm a big fan of selective automation. As I mentioned in discord, you might have hundreds of troops and a multifront war, I'm going to automate the entirety of say a couple/few unit types and let them run amok while I focus certain units against crucial targets. Meanwhile, I'm not trying to split my attention on if city J and city W are stealing my uranium or building a temple. We're at war people, what are you doing?! Definitely denouncing someone.

fyi, I super really appreciate you taking the time to give this feature a good go @SomeTroglodyte.

Having read how you were assigning to the queue, it makes sense now and I did try your way. So items are assigned then basically from disabled to the queue to isolate construction to that city. Now it makes sense.

That save should demonstrate nothing being superseded with a decision to build.

hackedpassword commented 10 months ago

Adding the right click menu in 4.8 is so awesome. Of course in context to this thread, the more challenging aspect didn't make it (yet?) which is not only understandable, it is commendable that the new feature was implemented in a productive way that carries much of the feature with it.

I don't think players have yet to comprehend the addition. I guess that's the norm though I'm this moderately paced environment of updating.

What's the disabled construction feature looking like now? Might that move forward?

SomeTroglodyte commented 10 months ago

didn't make it

No, it's just 2 separate PR's. Menu was already in the queue and of course I used that UI. You think global disabling by name, as in the demo, is worthwhile to add or would you rather think "nah, per city or nothing"?

hackedpassword commented 10 months ago

In my opinion, the matter that began this thread is the benefit goal. It remains a constant struggle with my own empire to handle themselves conducively to war objectives, not oooo I can build X yea that's a great option! without having consulted the strategic interests of other cities not the emporer/ss themselves. Wait, are we emporers? Has that ever been addressed?

btw the logical process described above would be a nice AI addition, verbalizing the thought (not a request).

I suppose another way to approach this could be flagging a do-not-build constructor, negative connotation where an internal list is referenced and any city that hasn't been told to build X, don't.

Per city has it's benefits also. When not caring about how other cities are going about their business, then you have some new cities and/or recently annexed cities and you want those to focus away from say culture or spirituality buildings, drop those from being queued and check back on them in 20-30 turns cause they're not really contributing anything to the civ at this point.

I started this thread for the former, so that's my vote. I see the second option as viable also, so both features would be great additions. If limited to one or the other, I'd point that call at the community.

SomeTroglodyte commented 10 months ago

Uh, found that last post hard to parse. I'll have to wrap this up as is, just ensure no known bugs. Had to redo the branch from scratch, merging resulted in chaos...

GameSettings

OK, just wanted to make sure no surprises. None in there.

"Nothing"

Treated "long ago", just didn't redo a fresh jar. Actually more of a problem with existing code, re-using it in new ways just brings the issue to light.

China save

Debugging... No, works as intended: militaryUnits > max(5, cities * 2) says the civ has enough military (5 units 2 cities and at peace), and since there's no other units allowed, no wish to build units.

hackedpassword commented 10 months ago

having consulted the strategic interests of other cities not the emporer/ss themselves

This is an open idea towards better AI.

hard to parse

A bit scattered, yes, verbalizing rationale can do that lol

works as intended

Hmm a formula, ok! Since the city/s have decided to produce nothing, would it be reasonable to produce a line under Cities in Notifications, something like "[city] reports no units need producing."? This seems similar to when terrain destruction occurred silently due to units configured to destroy terrain when attacking - a notification was included to convey what occurred removing confusion as to why the mystery destruction. Useful civ telemetry.

SomeTroglodyte commented 10 months ago

would it be reasonable to produce a line under Cities in Notifications, something like "[city] reports no units need producing."

... hmmm ... naaah. One, the decision is a bit removed from UI, two, at that point you don't know yet it won't choose anything else, cuz it's where a "pool" of worthwhile stuff is collected to then pick the best one. "Disable" removes at that stage from decision-making. AI uses the same code, only for them the blacklist is always empty.

Oh, and of course hotseat multiplayer share the blacklist - it's in GameSettings after all, so such ~masochists~ players would need to cooperate with this UI feature - or agree to ignore it.

hackedpassword commented 10 months ago

multiplayer

WHAT? LMAO how would that even work?? I've never played unciv in multiplayer so I'll go with whatever. That concept amuses me to no end. Players better pay close attention....

We'll see how this works in-game when published. I'll thank/blame/applaud/complain trying the results of said madness. Ok not madness but useful exclusion policy. Looking forward to it. :D

SomeTroglodyte commented 10 months ago

Sounds like you're asking how multiplayer as a concept could work - no idea. Schizophrenia, contrary to public prejudice, is not really multiple minds in one skull...

hackedpassword commented 10 months ago

@SomeTroglodyte

Your implementation of blacklisting is beautiful in execution.

Step 1: Disable construction of building/unit/wonder - > all cities respond, no one builds Step 2: Individual cities then may select to construct Step 3: Reestablish build across empire when desired

It looks good, feels good, plays good. :100:

SomeTroglodyte commented 10 months ago

Muchas gracias.

hackedpassword commented 10 months ago

This may or may not be intended - using the add to all cities option includes puppet cities. That supersedes their queue, when usually their queue is out of the player's control.

SomeTroglodyte commented 10 months ago

includes puppet cities

Unintended! Facepalm-level. Good catch.

hackedpassword commented 8 months ago

I love this menu.

hackedpassword commented 8 months ago

@SomeTroglodyte fyi found a problematic situation.

258 turns in, discovered a half dozen buildings under Disabled left over from the previous game that my civ should have been working on.

The immediate problem here is that for the rest of this game, I'll have to monitor the Disabled menu for unexpected disabled buildings.

However, a workaround will be to start a new game in the Future era, clear the menu, return to the current game.

edit: Stepped through new games for each era. Found one where 2 buildings were not revealed as disabled in any later era. Only one occurrence.