So a dragon with 10 HP left will be chosen before a healthy warrior? Personally I think damage should only be used as a tiebreaker.
Also, 0 strength units will always have equal values. Not so bad for slaves, but Corlindale might object.
These two things can be fixed by assigning world units an impossibly high value, so shouldn't be an issue. What are the limitations on number sizes in python, by the way? I'm thinking using 999999999999 as a multiplier could cause issues.
As to damage, I think I'll tone that down a bit, have it only apply half. So a unit with 99 damage would only be counted as 49.95% less than it's strength value.
I don't think adding a bunch of numbers to a multiplier is a good way to calculate value. Stick with either multiplication or addition. Using both makes it hard to predict. (This is one of the fundamental errors in Civ.)
How exactly would this work ? I don't think it's a fundamental error in civ at all, there are a lot of design concepts that wouldn't work well without it. But that discussion is for another time.
I've used mostly multiplication, but multiplying the multiplier is a horrible idea and would expand exponentially.
Can you explain how you'd make it work, perhaps ? The entire concept is based on user viewpoints of usefulness, so I don't think there are any real right answeres, merely the most agreeable ones.
You could replace the high value on Hero with a simple continue statement. This will immediately move on with the next iteration of the loop without considering anything further. Which in turn means that a Hero alone on a tile won't be the weakest unit there, somewhat strange but possibly desireable.
I'd like to tone that value down to something a little less likely to cause math errors, but still unfeasibly high. maybe 1000. Having heroes excluded is not desireable, I just want them to always be regarded as the most valuable.
Other conditions that should immediately remove the unit from consideration are Channeling III, immortal and world units. And I'd add a requireLiving argument to the function that determines whether non-living units should be skipped too.
I agree with you on 1 and 3 there, but 2? I don't think so. Immortal units you'd want to be MORE likely to consider, since sacrificing them won't actually make you lose anything.
While we're at it Adventurer is not worth the same as Hero. It's not even worth the same as Empower I.
You have a point, it's not as good as hero, but I still personally value it highly, it's rare and can't be achieved through any reproducible means except for two specific civs
Lesser added value, but still huge is if the units has had it's name changed, by the player if possible. Also provides a non intrusive way to mark a unit as valuable.
Can you give me a quick code snippet to test if the unit's name is different from the default ?
Good promotions: Chanelling I & II
Bad promotions: Skirmisher, first levels of werewolf, Withered, Burning Blood
good points, thank you.
Your code counts Strong and Weak twice, once as strength and again as promotions.
This is a good point, but I think it's alright. These two promotions are very powerful/very horrible, and doubling their impact on the calculations is fine with me.
Being a minion should probably add value... If you took the time to add it to an army, it's probably worth a little more than another that didn't make the cut.
A good point. How do I do this ?
Some units are inherently useless, and should have a great penalty. I'm thinking Slaves, Bloodpets and Scouts.
I'd generalise this a bit, slaves, unitclass warrior, and unitclass scout. The calabim are unlikely to have warriors other than bloodpets anyway, so a special exemption isn't needed.
You'll have to decide what to do about units with duration or that that have been summoned (tigers).
They will get banished to the bottom of the list and almost certainly be returned as worst.
---
One way to deal with options is to sort all units by value in a list and return it. The caller will have to go through the list from an appropriate end until he finds an acceptable unit.
This is a brilliant idea, and is infinitely better than how I'm currently trying to do it. I'm not too familiar with arrays in python though. Does it support multidimensional arrays, or would I need a strided list? Could you possibly show me how to put values into a list, and sort it ?
If unitList is a list of units that should be sorted (in this case all units belonging to the player in the tile) and valueFromUnit is a funtion that takes a unit and returns it's value.
Code:
unitList.sort( key=valueFromUnit )
sorts the list in place in ascending order.
How would I create unitList first of all ? And would the above code snippet test every element in the list and sort them accordingly? that seems pretty useful.
That is: unitList[0] will return the most useless unit and unitList[-1] will return the most valuable unit.
[/QUOTE]
I think rather than this, it'd be best for the function to just return the whole list, and let the caller extract what they want. For example, the Calabim will want the worst, living, non-vampire, non-animal, non-beast unit. Ogre Warchiefs will just sacrifice the nearest thing that comes to hand, whether it be summoned, undead, a tiger, etc.