Military Advisor

EFool - there are a bunch earlier on in this thread from me and Imhotep. See the first page.

Re combat type - I'd leave it as is first time thru and see how it looks.
 
·Imhotep·;6785642 said:
You might have a problem late game. I tested revision 709 with my recent Emperor game. MA broken. Went back to a save from 275 BC, same game. MA absolutely fine. The save for investigation is attached. Oh, and can you win the game for me ? :D ;)

Imhotep
Try revision 711. I also imported EmporerFools' deployment code into my version of BUGMA which probably means that I introduced some errors in it :D.
 
·Imhotep·;6723732 said:
I'd rather like to see an overview of units with the currently highest XP.

That's a sort order -- not a grouping. Can you think of a way to group units by XP, for example by level? Okay, Ruff suggested by XP and level as well.

promotion

Grouping by promotion could work, but it has some quirks. Do you show those with Combat 3 in the Combat 1 group as well since they have C1? Same for other promotions with multiple levels.

Listing based on health status, and if the unit can be upgraded.

These both seem like candidates for filtering as opposed to grouping or sorting by adding checkboxes ("Injured", "Upgradeable" and "Promotable"), though grouping would work as well by creating two groups for each, or even a % scale in the case of Health.

Is "Movable" desired for finding units that can still move? It will highlight all defenders, so it's probably useless.

Did I miss any others?

Certainly, a sort order when displaying individual units is a good idea. XP, level, health, strength (normal or actual).

I'm wondering now if we could start with one of the other community MAs for this tab? IIRC, there's a good one but the complaint is that it's slow to load. I could take a look at it and see if I can optimize it. Any recommendations for one with great features?
 
Is there anyway we can give it a reduce size healther bar, similiar to Ruffs Thread Index?

Can you please elaborate? Are you saying to shrink the GG bar? Or are you talking about grouping by health?
 
well - unit combat type is a sort order too. I was thinking that the list box would show a list of numbers so that you can see how many units you have that are 15 XPs. I see your point re promotion - can they get added in twice. I hate having to search for medic units.

I mainly use F5 for finding units that are hiding and for getting a unit count. Level would be good so that you can see which unit is closest to unlocking the HE and Pentagon.
 
Yes, shrink the GG bar, and use it as a health bar... or maybe take the health bar that hovers over units, and have it displayed there?

Maybe, instead of adding a sort order for all promotions, just add it for ones that you use often. Medic Units, City Attackers, Woodsman II... things like that.
 
Stupid unit upgrades. I found this code

gc.getUnitInfo(k).getUpgradeUnitClass(iUnit)

... which is a boolean but I cannot figure out if it shows that k is an upgrade of iUnit or the other way around. Look at this list ...

Unit to test ... Maceman ... the first boolean is k then iUnit and the next is them reversed. From the civopedia ... mace upgrades to rifle or Grenadier (which in turn, upgrade to infantry, etc. I'm hoping to get a list of all units that a mace could become.
Spoiler list of units :

Lion False False
Bear False False
Panther False False
Wolf False False
Settler False False
Worker False False
Fast Worker False False
Scout False False
Explorer False False
Spy False False
Cereal Mills Executive False False
Sid's Sushi Executive False False
Std Ethanol Executive False False
CreateCon Executive False False
Mining Inc Executive False False
AlumCo Executive False False
Civ Jewels Executive False False
Jewish Missionary False False
Christian Missionary False False
Islamic Missionary False False
Hindu Missionary False False
Buddhist Missionary False False
Confucian Missionary False False
Taoist Missionary False False
Warrior False False
Quechua False False
Swordsman False False
Jaguar False False
Gallic Warrior False False
Praetorian False False
Axeman False True
Phalanx False True
Vulture False False
Dog Soldier False False
Maceman False False
Samurai False False
Berserker False False
Spearman False False
Impi False False
Holkan False False
Pikeman False False
Landsknecht False False
Musketman False False
Musketeer False False
Janissary False False
Oromo Warrior False False
Rifleman False False
Redcoat False False
Grenadier False False
Anti-Tank False False
Infantry True False
SAM Infantry False False
Mobile SAM False False
Marine False False
Navy SEAL False False
Paratrooper False False
Mechanized Infantry False False
Archer False False
Skirmisher False False
Bowman False False
Longbowman False False
Crossbowman False False
Cho-Ko-Nu False False
Chariot False False
War Chariot False False
Immortal False False
Horse Archer False False
Numidian Cavalry False False
Keshik False False
Knight False False
Camel Archer False False
Cataphract False False
Conquistador False False
Cuirassier False False
Cavalry False False
Cossack False False
War Elephant False False
Ballista Elephant False False
Tank False False
Panzer False False
Modern Armor False False
Gunship False False
Catapult False False
Hwacha False False
Trebuchet False False
Cannon False False
Machine Gun False False
Artillery False False
Mobile Artillery False False


The CvPediaUnit.py file in 'def placeUpgradesTo(self):' has 'gc.getUnitInfo(self.iUnit).getUpgradeUnitClass(k)' and shows the k unit button on the iUnit screen. There is also some other code that just clears up the unique unit issues (I think).
 
I'm wrestling with how to add sort/group options and keep the list usable at the same time. For example, if you have a lot of units and select "Promotion"/"Unit Type" you'll see each unit type listed below each promotion with at least one unit of that type having the promotion. This will mean a lot of scrolling to see the totals:

Code:
ALL UNITS (182)
  NONE (33)
    Warrior (2)
    Archer (10)
    Axeman (4)
    Swordsman (1)
    Spearman (3)
    Chariot (6)
    Galley (5)
    Trireme (2)
  COMBAT 1 (18)
    Warrior (1)
    Archer (1)
    Axeman (3)
    Swordsman (2)
    Spearman (4)
    Chariot (2)
    Galley (1)
    Trireme (4)
  COMBAT 2 (5)
    Warrior (1)
    Spearman (1)
    Chariot (2)
    Trireme (1)
  ...
I limited that to the early years when you have only a few promotable unit types (workers, settlers, spies, etc. would not be shown in the promotion view). Imagine this list when you've got 20 or so types.

Perhaps just adding a "None" grouping would solve this. You could select "Promotion"/"None" and see just the list of promotions without the unit type breakdown below it.

For the filtering checkboxes -- injured :yuck:, promotable (a star), can move :move:, upgradeable :strength: -- I'll need DDS graphics instead of the font glyphs. Is anyone particularly adept at The Gimp or some other graphics program and can make DDS versions (or find if they exist already) of these characters? If so, could you do the same for :food:, :hammers:, and :commerce:?
 
For the filtering checkboxes -- injured :yuck:, promotable (a star), can move :move:, upgradeable :strength: -- I'll need DDS graphics instead of the font glyphs. Is anyone particularly adept at The Gimp or some other graphics program and can make DDS versions (or find if they exist already) of these characters? If so, could you do the same for :food:, :hammers:, and :commerce:?
I can do that. Any thing else that you need?
 
If you could sketch out some layouts, that'd be great. Space will be a premium, so I'm thinking we could move the GG bar elsewhere (to the bottom panel maybe?) or make it smaller and then put the group/sort/filter options above the map as you suggested.

Code:
[-------- L E A D E R H E A D S ---------]

Group: [Menu1] [Menu2]    [--- L I S T ---]
Sort: [Menu]  [x Details]
[---- Filter Buttons ----]

[------- M A P --------]
I figure two levels of grouping should be okay, yes? I'm not sure about sort yet. It really only applies when you are viewing the individual unit details. A button for that needs to be created as the current one is a bit large: "+/- Show Unit Details".

I've got the code to store define and capture all the groupings for the ones we discussed:

  • Combat Type
  • Unit Type
  • Promotion
  • Location
I'm currently dealing with Promotion as it is the first one to require multiple values for a single unit. None of this is being displayed or has even been tested in Civ yet, so don't get too excited. ;)
 
NEAT WORK GUYS ! The MA now works perfect with my late game save, and the map is drawn correctly when switching between Deployment and Sit-Rep. One minor issue with Sit-Rep: If the human can build only an obsolete version of the unit the AI has (in my case I have Tanks and Fighters, he has Modern Armour and Jet Fighters) the obsolete version shouldn't be listed as strategig advantage... other than that: very cool, this is a masterpiece !

Imhotep
 
·Imhotep·;6786742 said:
One minor issue with Sit-Rep: If the human can build only an obsolete version of the unit the AI has (in my case I have Tanks and Fighters, he has Modern Armour and Jet Fighters) the obsolete version shouldn't be listed as strategig advantage... other than that: very cool, this is a masterpiece !
That is a known issue that I am trying to fix. I am not sure the python code allows me to do it ... or, I am using the wrong code (this is much more likely) :D.
 
A button for that needs to be created as the current one is a bit large: "+/- Show Unit Details".
Isn't that button just text and so we can shorten it in python? Suggest same for sort option.

Re GG progress bar - what about shoving it up with 'Military Advisor' to get it out of the way? Not pretty but ...
 
MA status ...

  • threat index - need to settle on the initial calculation routine and put it into play
  • hide threat index if cannot see power - could include comment "n/a"?
  • strategic units on the main screen
  • hide strategic resource information if no tech and resource trading - see if I can include comment
  • scrolling - looked at this last night, copied the code and it didn't work - will look again and then probably put it aside - done and committed (revision 645)
  • Add list of leaders that the current leader has a DP with
  • Add list of leaders that the current leader has vassalaged
  • Adjust Threat Index to include reduction value for DPs
  • Adjust Threat Index for leaders that are vassals (duplicate their masters or completely remove?)
  • master icon - not enough room
  • remove strategic units if player can build an upgrade of a unit - currently looking at this but the code I see doesn't work :hmn:
  • cycle thru cities so that all units possible are included
  • expose all text to XML for multi-language support
  • BUG: If you open the MA with the Sit-Rep tab displayed, switching to the Units tab doesn't draw the minimap

MA status for future release ...

  • free up the main sort criteria (currently unit combat type) so that the user can select what it is - need drop down, refresh button and auto-refresh check box <-- EmperorFool has stuck his hand up for this one - good luck!
  • glance screen
  • worst enemy icon (only when patch has been released)

Currently working on cycling thru all cities to pick up all units that can be built.
 
I'm pretty sure I can write some code to help you detect obsolete units. It will set up an obsoleted-by table when the screen opens and then use the set of all units you and the AIs can build to remove obsolete ones.

Psuedocode:

Code:
screen.open:
    build obsolete table
    build list of units player can build

for each non-player civ:
    build list of units civ can build
    draw list of player advantages using civ-unit-list
    draw list of civ advantages using player-unit-list
Give me a few minutes* and I'll post some real code. :)

* Actual results may vary. Ask your doctor if you experience bleeding gums or severe flatulence.
 
Quick question: If you can build Musketman, should the screen show Musketeer as an advantage for French AIs? If so, I assume it should not show Musketman as an advantage for you; they can't each be better than the other.

Of course, some would argue that Swordsman is better than the Aztec replacment -- the one that builds without Iron but is weaker. In this case, both should be shown.

The simple solution is to treat civ-specific units as the regular kind. In the first example, neither Musketman nor Musketeer would be displayed.

Which of the three options do you prefer?
 
Here's a first attempt. It considers Musketman and Musketeers to be unrelated. They will each display in the advantages in the case I outlined above. This handles cases where the civ-specific unit isn't better than the default unit in all cases. It's left up to the player to decide.

You'll need to alter the code that you use to generate the list of units that a civ can build. I'd like to introduce you to the handy set() class. It holds a collection of objects (in this case unit type IDs), but each value will only appear once no matter how many times you add it. They are great for comparing to each other (union, difference, subset, etc).

Here's some sample usage code to highlight the functions you'll likely need to use:

PHP:
units = set()  # create a new, empty set
units.add(5)  # put 5 into the set
units.add(2)  # put 2 into the set
units.add(5)  # 5 already in set, nothing happens

if 5 in units:
    print "5 is in the set"
if 1 not in units:
    print "1 is not in the set"

other = set()
other.add(1)
other.add(2)  # other == (1, 2)

print units & other  # intersection --> (2)
print units | other  # union --> (1, 2, 5)
print units - other  # minus --> (5)
print units ^ other  # items only in one set or the other --> (1, 5)
                     # equivalent to union - intersection
Now here's the code so far. Note: I have not tested this at all.

PHP:
def buildObsoleteGraph(self):
	NUM_UNITS = gc.getNumUnitInfos()
	
	# Create graph of single-step upgrades (Swordsman to Maceman)
	self.obsoleteUnits = {}
	self.completeUnits = set()
	for iUnitA in range(NUM_UNITS):
		infoA = gc.getUnitInfo(iUnitA)
		upgrades = set()
		self.obsoleteUnits[iUnitA] = upgrades
		for iUnitB in range(NUM_UNITS):
			infoB = gc.getUnitInfo(iUnitB)
			if infoA.getUpgradeUnitClass(infoB.getUnitClassType()):
				upgrades.add(iUnitB)
	
	# Now add all transitive upgrades (Swordsman to Rifleman)
	for iUnit in self.obsoleteUnits.iterkeys():
		self.buildObsoleteClosure(iUnit)

def buildObsoleteClosure(self, iUnit):
	upgrades = self.obsoleteUnits[iUnit]
	if iUnit not in self.completeUnits:
		nextUpgrades = set()
		for iNextUnit in upgrades:
			nextUpgrades |= self.buildObsoleteClosure(iNextUnit)
		upgrades |= nextUpgrades
		self.completeUnits.add(iUnit)
	return upgrades

def isObsolete(self, iUnit, enemyUnits):
	upgrades = self.obsoleteUnits[iUnit]
	return len(upgrades & enemyUnits) > 0
 
Quick question: If you can build Musketman, should the screen show Musketeer as an advantage for French AIs? If so, I assume it should not show Musketman as an advantage for you; they can't each be better than the other.
I was going to treat UUs as totally different units. So if Rome can build preats and I can build swords, then that is a strategic advantage to both of us. Admittedly, not much of an advantage to me but the user will have to just work those out by himself.
 
Great! That's exactly what the code that I posted does. It wouldn't be too hard to make them equivalent, if you change your mind.

I'm against making one better than the other simply because the decision is a) subjective and b) situational. Beserker is pretty much the same as Maceman on a Pangea; the Iron-less Swordsman is usually not an advantage; Praets always kick ass over Swordsman, etc.
 
Top Bottom