"Love system"

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
adamo
Posts: 35
Joined: Sun Nov 16, 2014 6:48 pm

"Love system"

Post by adamo »

Hello!

I would like to add an option that improves the AI love/hate system (except for all other AI love factors), when a human plays with a lot of AIs. The main purpose is to balance the gameplay (equal the chances) when there are a lot of players. In other words, the strongest/most powerful guys would be more likely attacked by the other players than the weaker ones - in some way, that would flatter the chances to win a game, because in most games, gaps between the strongest guy and weaker ones are too large.

This could be done in several ways.

1) THE STATIC HATE SYSTEM: every 10 (or 20... or 30...) turns, the program simply compares the overall power (strength) of civilizations (population, science, wonders, military factor and so on...) and arrange a queue (nr. 1 = best civ on a list, nr. 2 = second civ on a list, nr. 3 = third civ on a list, etc). The first player on a list (most powerful/developed one) always gets specific, predefined additional AI hate factor (say, AI LOVE minus 20). The second one on a list always gets respectively lower value (AI LOVE minus 10). And so on.

From the program's perspective, it would look like this:

- the 1st player (with the greatest overall strength factor) gets (-20) LOVE,
- the 2nd player (with the second overall strength factor) gets (-10) LOVE,
- the rest one (from 3rd to 10th) gets zero (0) LOVE (= remains untouched by this factor).

Of course, it could be arranged in a different way:

- the 1st one gets (-15) LOVE,
- the 2nd one gets (-10) LOVE,
- the 3rd one gets (-5) LOVE,
- the 4th one gets (0) LOVE,
- the 5th one gets (0) LOVE,
- ...

As you can see, the following players on a list (4th, 5th, and so on...) are untouched by this factor.

Of course, this could be reversed: instead of "hating" the strongest players, the weaker ones could get some love bonus... It's all up to the designer:

- the 1st one gets (-15) LOVE,
- the 2nd one gets (-10) LOVE,
- the 3rd one gets (-5) LOVE,
- the 4th one gets (0) LOVE,
- the 5th one gets (0) LOVE,
- ...
- the 9th ine one gets (+5) LOVE,
- the weakest one gets (+10) LOVE.

This is the simplest solution to code, but has some disadvantages - all factors have to be already predefined, which doesn't always have to fit well: when the first player has 35000 overall strength points, he gets most of the hate (-20 LOVE), because he's in the first place on a queue, while the second player, which is almost the same powerful (34000 overall strength), gets way less hate (-10 LOVE). We can set it to (-20) and (-15) instead, but then the player with 50000 overall strength will get almost the same hate as the second one in a queue, which has only 12000, which wouldn't be fair for the second guy in a queue.

2) THE DYNAMIC HATE SYSTEM: every 10 (or 20... or 30...) turns, the program compares the overall strength of civilization, list them in a queue, checks the quantity (value) of differences between players, and spreads the AI hate from a predefined, but dynamic pool between a players. The spread of this pool is respectively bigger when the inequalities of overall strength are higher, so most of it it can be all - theoretically - taken by the first one, and it's fair, because he's powerful.

Let's suppose there are 10 players, from which two of them are clearly outstanding from the others. The program computes the AI overall pool, which can be lower or higher, depending on the inequalities between players, and spreads it between them according to their overall civilization power: the first one, as the most powerful one, may get AI LOVE (-40), while the second may get (-20). When the inequalities are lower, the first one on a list may get (-10) additional AI LOVE, while the second may get (-5).

Suppose we take five best civs and spreads the hate from 30 points of so-called "hate pool".
From the program's perspective, it would look like this:
- the 1st one has 10000 points of "power"
- the 2nd one has 8000 points of "power"
- the 3rd one has 6000 points of "power"
- the 4th one has 5000 points of "power"
- the 5th one has 4000 points of "power"
- the 6th one has 3500 points of "power"
- the 7th one has 3000 points of "power"
- the 8th one has 2500 points of "power"
- the 9th one has 1000 points of "power"
- the 10th one has 500 points of "power"

The overall pool is 43500, but we consider only 5 first CIVs - so the effective pool is 33000. Now we need to share the defined AI HATE value (say, 30 points) between these civs:

- the 1st one gest (-9) AI LOVE,
- the 2nd one gets (-7) AI LOVE,
- the 3rd one gets (-6) AI LOVE,
- the 4th one gets (-5) AI LOVE,
- the 5th one gets (-3) AI LOVE.

Of course, we can consider only three first civs. This way, when he have very powerful civ and the bunch of weak ones, the powerful one gets most of the pool. Let's say the first civ has 50000 points of "power", while the second and third has about 10000 each. When we consider three more powerful civs with a pool of 30 "hate points", we have to divide 30 points between the 70000 pool. This way:

- the 1st one, with 50000 points of "power", gets (-22) AI LOVE,
- the 2nd one, with 10000 points of "power", gets (-4) AI LOVE,
- the 3rd one, with 10000 points of "power", gets (-4) AI LOVE.

We can increase the "hate pool" to, say, 50 points. This way we get:

- the 1st one, with 50000 points of "power", gets (-36) AI LOVE,
- the 2nd one, with 10000 points of "power", gets (-7) AI LOVE,
- the 3rd one, with 10000 points of "power", gets (-7) AI LOVE.

Of course, as in the first example, this could be reversed: instead of "hating" the strongest players, the weaker ones could get some love (reversed pool)... It's all up to the designer.

3) (UN)HOLY ALLIANCE/MORTAL COMBAT: when a civilization starts building a spaceship, it automatically declares war to all other civs, which establish an (un)holy alliance against the possible winner: for example, when there are 10 players left on a map, the civ, which started building a spaceship, has a pact (military alliance) of 9 other civilizations against himself. They stop fighting each other and starts fighting the threat. It seems reasonable - it's their last chance to survive; if they won't do that, they will all fail. It's a mortal combat - the only thing they can do is to immediately attack/nuke the possible winner. When the threat is prevented (the civ being nuked/flooded so hard that he stopped building a spaceship), the pact is cancelled and the game goes on normally, until the next civ will start building a spaceship.

There are two possibilities to be consider:

=> the civilizations, that formed a pact against a threat ("unholy alliance"), CANNOT start building a spaceship until a threat is cancelled (after the threatening civilization eventually stops building spaceship - possibly because it was hitten so hard by others it simply can't build it, or it was "persuaded" to stop doing that). After the threat is gone, it all starts over: first civ, which would start building a spaceship, has a new pact against himself.

=> the civilizations, that formed a pact against the threat ("unholy alliance"), CAN start building their own spaceship - but that would mean they are automatically excluded from an alliance. The civ, which will do this, is treated just as another threat (the AIs thinks: "there are already two threats: now we need to nuke not only Russians, but also Zulus").

Yes, I know there is already a "hate" against a civ, that started building a spaceship, but it's uneffective. All the others have to immediately stop the threat; to do that, there need to be "all against one", immediate "mortal combat" aggression. All in all, when someone started building the spaceship, it's an ultimate fight for life for all the others!



*English is not my native language, I was writing this post with dictionaries, so sorry for possible mistakes or incoherences*
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: "Love system"

Post by bard »

I agree completly that the "love system" is the most important part of the AI code in order to get balanced and challenging games against the computer.
I think the way the AIs create alliances and enemies affects much more the game, than any bonuses or penalties given by the different difficulty levels.
In current freeciv, it is really hard to play a game where the forces are even, either you are fighting for survival against continuous waves of hostile Ai units, or you are ahead and the enemies are no longer a real threat. There is few room in between, and I agree the best solution would be a system where AIs cooperate to ally against the most advanced player in a dinamic way.

I do not know much the code of the AI in freeciv, and I can't evaluate properly your suggested implementations, but I find your idea very interesting, and I hope some developer gets interested.
cazfi
Elite
Posts: 3091
Joined: Tue Jan 29, 2013 6:54 pm

Re: "Love system"

Post by cazfi »

In the past AI had "lobster logic" -> everyone allied against strongest player, so that in theory the second weakest was about to win (when there's just two players left, the weaker one has nobody to ally with against the stronger). I don't know the details how that system was a failure, but it was scrapped as failed experiment.

AI already declares war to those who launch a spaceship. I'm not sure about what happens when one starts to build it - probably just much loss of love. Actually I don't see why allies are doing (or should do) that, especially when allied victory is enabled.
The Square Cow
Veteran
Posts: 53
Joined: Wed Nov 19, 2014 5:47 pm

Re: "Love system"

Post by The Square Cow »

When Allied victory is enabled, then an effective strategy (but not fun) would be for AI to ally with the most powerful alliance. This wouldn't be fun thought because most games would end as soon most people knew most other players, because everyone would rush to join the biggest alliance and the game would be over in a turn.

If lobster logic has failed, maybe a more fun way would be for the AI to join the second strongest ally block. This should lead to many close calls as the near equal alliances clashed. It would also lead to an more even difficulty though out the game, because as the player became more powerful they would have to face larger alliances. It would also lead to betrayals because when one side was weakened, some AI players would switch to the loosing side.
adamo
Posts: 35
Joined: Sun Nov 16, 2014 6:48 pm

Re: "Love system"

Post by adamo »

There is a simple way to add more fun into the game using the "Unholy Alliance" (total war against a civilization, that start building a spaceship, described above): it's just the case of making the construction of spaceship harder (=longer) than it is now. This could be done just by increasing the number of shields for a specific part: if Spaceship Component costs 160 shields, we might increase its number to 1600 shields; Spaceship Module might cost 3200 instead of 320 and Spaceship Structural might cost 800 instead of 80.

Why?

When a player starts building a spaceship, every other civ should do everything to stop the threat: to nuke the enemy or to flood him with the hordes of units, until he stops building it and the crisis is prevented. Now if the spaceship is harder to build, other civilizations would simply have more time to force you to stop building it. The spaceship is the ultimate challenge (it means winning a game), so, before consider building it, be prepared for the well rush (which means maximum hate for a civ, which dare to do so).


So, I opt for two alternative options:

=> "Panic" Flag: if you choose this setting, the civs, which faces the danger ("look guys, somebody just started building a spaceship!"), forms "Unholy Alliance" against the threat, and does everything to nuke/beat the enemy. If you want to explore the Universe, you better be prepared for an Ultimate Battle!

=> "Challenge" Flag: if you choose this setting, the base spaceship cost will be higher than normal (SS Structural, SS Component and SS Module are simply multiplied by given value). With the first flag set, it gives your opponents more time to "persuade" you to stop building a spaceship.

So, before start building SS Structurals, it's wise to make up some SDI Defence units and be prepared for the nuclear winter...
adamo
Posts: 35
Joined: Sun Nov 16, 2014 6:48 pm

Re: "Love system"

Post by adamo »

@cazfi
In the past AI had "lobster logic" -> everyone allied against strongest player, so that in theory the second weakest was about to win (when there's just two players left, the weaker one has nobody to ally with against the stronger).
The typical disadvantage of the badly balanced static hate system. I suppose it might even work well in the unending game (no spaceship win), because of the dynamic military power; but it would definitely not work when the strongest guy is already beaten by others and there's no time to do the job with the second one (which can easily launch the spaceship after all). It's all the matter of time, which left for the sudden ending (the strongest one is impaired, so the second one does the job). My idea was to implement a dynamic evaluation, which consider the "overall strength balance" - at least for a regular game with the spaceship. It would be best if the program overestimates the scientific advancement (over the other factors), and takes it as a base for calculating the overall civilization strength. Because, all in all, in a regular game, it's the science, that matters the most (it's because of the spaceship; in a non-spaceship game, when others are scientifically more advanced, you could theoretically win by the brute force - one hundred legions would always beat one single tank, if you properly set up the game conditions*)...

* - in Mao's theory of war, brute force wins; a nonadvanced, militarized civ with 100 hundred cities and a mass of cannonfodder, ruled by communism, would most likely beat advanced, highly developed civ with just a few cities, ruled by democracy - nukes wouldn't help here much; but if the game can finish suddenly (a spaceship), it won't work that way, thus, in Civilization, the nonadvanced regime can flood the enemy by its cannonfodder, but got no chances to win a game by launching the spaceship

This is why I would defend my idea of dynamic hate system (in a dynamic system, it's not the matter of a simple queue, but also how strong the enemy/enemies are - and react adequately towards the "overall strength" gap; in real life, there are often alliances of weaker states against the powerful empire, but the more powerful the empire, the tighter is the alliance. I'm not saying these alliances (bunch of weak guys against the strong one) are always successful, but at least they stand up together against the threat. I'm not too keen with the Game Theory, but if there are a lot of players and only one possible winner, there should be dynamic alliances all over the time.


And, IMO, it's way too easy to build a spaceship; it's the matter of few dozen turns, which doesn't give the others (weaker ones) sufficient time to react.
skinpenthar
Posts: 1
Joined: Thu Feb 26, 2015 5:51 am

Re: "Love system"

Post by skinpenthar »

When a player starts building a spaceship, every other civ should do everything to stop the threat: to nuke the enemy or to flood him with the hordes of units, until he stops building it and the crisis is prevented. Now if the spaceship is harder to build, other civilizations would simply have more time to force you to stop building it. The spaceship is the ultimate challenge (it means winning a game), so, before consider building it, be prepared for the well rush (which means maximum hate for a civ, which dare to do so).
__________________________
Get Testking asvab practice test for test king and Testking istqb certification success guaranteed. Our high qualitycallutheran.edu you well before Stanford University of selftestengine gmat.
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: "Love system"

Post by bard »

And, IMO, it's way too easy to build a spaceship; it's the matter of few dozen turns, which doesn't give the others (weaker ones) sufficient time to react.
I agree, I opened this ticket https://gna.org/patch/?5996 in order to double the costs of spaceship parts, in case you have any suggestion.
Ozor Mox
Posts: 45
Joined: Wed Apr 02, 2014 12:15 pm

Re: "Love system"

Post by Ozor Mox »

I definitely think making the spaceship more expensive and therefore more difficult to build is a good idea. The only thing is, at the moment the AI reduces its love with any civilization building a spaceship, but won't usually declare war until they actually launch it. While I have seen a spaceship destroyed by capital capture, this is usually way too late to do anything, as most spaceships will arrive in less than 15 turns, even if it took much longer to build. It's possible to change the spaceship parts cost in a ruleset and run an AI only game to test this.

In terms of the way AI love works in general, I've played around with this a bit in the past using a custom ruleset with various values of "Gain_AI_Love" to make the AI more peaceful. It works pretty well, although it can swing the other way and make the AI too happy to be in one global alliance! Another idea is to have Gain_AI_Love triggered by certain wonders or techs, so that the earlier game is more aggressive and the late game is more peaceful.

I'd like a ruleset setting that adjusts how much love tends towards zero. This would mean that a higher setting would cause the AIs to be less extreme in their love or hate, so you would see more relationships that are just peace, rather than war or alliance, allowing wars to break out and peace to be made throughout the game.
bard wrote:I agree, I opened this ticket https://gna.org/patch/?5996 in order to double the costs of spaceship parts, in case you have any suggestion.
To answer your question on the ticket, I think the way it works is that if you launch a spaceship without every possible part, it will arrive faster but with less than 100% reliability. This means if someone has launched a full spaceship before you have completed yours, you can potentially launch a less completed spaceship and beat them, but with a chance it might explode horribly mid-flight and you won't win! Someone more knowledgeable correct me if I'm wrong!
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: "Love system"

Post by bard »

I agree what you say about AI love. Another limitation of "Gain_AI_Love" is that it depends a lot on the number of players. The same amout of AI_Love that creates a peaceful game with few players, could result in constant wars when there are many players, so it is hard to balance in the ruleset.
Ozor Mox wrote:I definitely think making the spaceship more expensive and therefore more difficult to build is a good idea. The only thing is, at the moment the AI reduces its love with any civilization building a spaceship, but won't usually declare war until they actually launch it. While I have seen a spaceship destroyed by capital capture, this is usually way too late to do anything, as most spaceships will arrive in less than 15 turns
I agree, too.
Ozor Mox wrote:To answer your question on the ticket, I think the way it works is that if you launch a spaceship without every possible part, it will arrive faster but with less than 100% reliability. This means if someone has launched a full spaceship before you have completed yours, you can potentially launch a less completed spaceship and beat them, but with a chance it might explode horribly mid-flight and you won't win! Someone more knowledgeable correct me if I'm wrong!
What you describe is true for most spaceships parts, but not for population modules.
After some tests, I have verified that you can win the game with a spaceship that has only one Habitation module (pop 10000, while max is 40000), and it will have a 100% chance of success as long as it incudes 3 modules in total (habitation + energy + life support), and as long as the structural parts connect them all with the propulsors. In this case, if you build all the 24 space components, you need 20 structurals, and the ship will arrive in 7 turns.
Post Reply