July 4th, 2016, 05:43
(This post was last modified: July 4th, 2016, 05:48 by Seravy.)
Posts: 10,463
Threads: 394
Joined: Aug 2015
I discovered a bug today that prevents AI players from trading spells to each other.
After fixing the bug, trading now works.
Question is, how often and/or under what conditions should the AI be able to trade?
Currently the only requirement is not being at war, and a successful trade requires roughly 13 points more in relation than a successful wizard's pact. There is no condition on what the spell should be, they pick one spell at random from the other and trade it. "Armageddon for Holy Weapon, sure no problem. Next time can I have Archangel for Fire Bolt?". I don't think I can change that, even if I make one of the wizards insist on getting an equal or better deal, the trade is still uneven, just for one side instead of both. Forcing exactly equal would make trades near impossible. Space in code is very limited - we can say nonexistent - too.
This allows AI wizards to spread around all their spells if they're on good terms, but not if they're enemies and rarely if they're neutral.
I did two test runs. In both the two wizards were a maniacal and a lawful. Difficulty was hard.
1. The two wizards made a wizard's pact, and were on good terms, the pact kept improving relations. In 4 years they traded 8 spells under these conditions, but not until the pact was formed.
2. The two wizards had no pact and relations were neutral, slightly negative. No pact was formed and no trade was made at all. Eventually war started.
I think this might be reasonable to keep as is.
Posts: 488
Threads: 51
Joined: Apr 2012
Gah...another one! I've been playing the game wrong all these years. I would keep dangerous spells to myself not because the computer players would use it, but because they would trade it amongst themselves. MoO computers did this. Although I believe they did check the value of the tech before trading.
That kind of sucks the spells are random, it kind of takes away from the whole trading idea. Trades need to be less frequent if they're going to be random IMO. What will happen is the CPs will just sort of become identical, exchanging all possible spells as time goes on. This takes away personality from them and makes them samey.
Posts: 10,463
Threads: 394
Joined: Aug 2015
(July 7th, 2016, 17:18)Tiltowait Wrote: Gah...another one! I've been playing the game wrong all these years. I would keep dangerous spells to myself not because the computer players would use it, but because they would trade it amongst themselves. MoO computers did this. Although I believe they did check the value of the tech before trading.
That kind of sucks the spells are random, it kind of takes away from the whole trading idea. Trades need to be less frequent if they're going to be random IMO. What will happen is the CPs will just sort of become identical, exchanging all possible spells as time goes on. This takes away personality from them and makes them samey.
Yeah I agree, if they trade everything that's not very fun. Fortunately only wizards with a high relation will do that...but that might not be limiting enough. Especially because similar books usually result in better relations, and that overlaps with what is needed to trade the spells.
The bad news is this is in a segment with no free space - if I want to make it consider value I will need to not only write the entire code (not easy but I can copy the one used for the AI to human trade offers) but also put it into another segment and use a far call to access it. The other problem is the condition. Which AI should the trade favor? Relation is symmetric here, not like between human and AI. Or should it be a range like, +/- 50% value either way?
Maybe we should see how bad it gets -if at all - without changing it first.
July 7th, 2016, 17:50
(This post was last modified: July 7th, 2016, 17:52 by namad.)
Posts: 520
Threads: 8
Joined: Jul 2011
Ideally it would just trade equal rarities.
Research cost doesn't really matter much compared to spell picks.
The problem though is that the ai cannot see the list of spells it has available to research next and realize trading those would be dumb. The human player tries his best to either trade worthless spells for spells he will research soon but hasn't yet. Or better yet ANYTHING AT ALL for a spell he's confirmed isn't in his books.
The fact that the ai cannot possibly consider that difference in human to ai relations means that ai to human spell trades ONLY benefit humans. As such I think AI's should get to trade, even if they do it entirely randomly there is at least a random chance the ai will make a smart trade, additionally it will get harder for the player to have any spells left over that the ai doesn't already have the player can bait the ai into giving them something good for.
This is a fairly large problem on extreme and impossible because the AI has more books than you, is very likely for you to be at war with them, and they have like double your research.
On impossible the ai has a lot of random spellbooks which makes it more likely they'll be able to trade a lot of spells with other ai's because they'll be more likely to have 2or3 random books off-color added on.
TL;DR if spell trading becomes common between ai's maybe the player should have his spellbook translated. If the ai's are trading spells amongst each other, and have a massive impossible cheating bonus to research speed they're not going to be missing very many spells. So, the odds of a player researching all of his uncommon or rare or very rare spells in his spellbook (minus the 7 translated spells shown always) while the ai still has any need to trade with them. will never occur ever.... meaning it will be quite hard for the player to get more spells than 4*books. At the same time though this isn't a factor the ai considers, they mostly as far as I know just consider rarity?
In ten games, when ai couldn't spell trade, half on hard, and half on extreme, I think I managed to trade for 2-3 spells that weren't in my spellbooks, and I gave up on that goal and traded for another 10-20 spells I didn't really need at all but I traded for, for the free research bump. Wars, and lack of shared books with only 4 opponents is so common that trading rarely happens, in MoO2 there's no such thing as shared books and there's like 8 opponents and you can trade with anyone anytime you're not at war.
Posts: 10,463
Threads: 394
Joined: Aug 2015
(July 7th, 2016, 17:50)namad Wrote: Ideally it would just trade equal rarities. Each spell has a calculated AI trading value - used for human trades - ideally it should use that. Spell Blast is worth trading Djinn for. Rarity is the base but there is a modifier.
Quote:The problem though is that the ai cannot see the list of spells it has available to research next and realize trading those would be dumb.
It can. Those spells have lower trading value. In fact any spell they can research in the future - even if not already in the list - are worth less.
Quote:The fact that the ai cannot possibly consider that difference in human to ai relations means that ai to human spell trades ONLY benefit humans.
The AI knows which spells you will be able to research, you do not - unless you bothered to decipher the runes in your spellbook. They'll prefer to trade spells you'll get in research and prefer to receive spells they would not otherwise get. They also know which spell is worth what since each has its own value modifier I personally adjusted.
The problem is, when the AI trades with the human the goal is clear. The AI should try to benefit from the trade. If the AI trades with another AI, which AI should benefit? If they both want to get the more expensive spell they'll never ever trade.
Now that I think about this, even if we set up something like "value should be +-5 value points fort trade", it doesn't make a big difference in the end result unless they had very uneven spell distribution. (like one AI only having commons for trade while the other had only rares)
If one AI has 10 rares and the other has 10 rares, they can trade all 10 anyway.
The main problem I see is, trading for a spell you can research means you get a higher rarity spell for research that many RP earlier. If the AI trades a bunch of commons and uncommons, they'll have rares twice as fast.
AI wizard's pacts and alliances are bad enough on their own since they don't lose their units, if they also get a research advantage on top...
What if we also made the AI conduct positive diplomacy less often?
As is, they do it once every 7 (impossible) to 15 (easy) turns. So that gives them like 10 chances to trade on Extreme in 100 turns...wait, that isn't so bad, is it? Okay, maybe it is. That's pretty much everything they can trade in the course of a typical 250 turns game.
Probably the best solution would be to still let them select at random, but don't do the trade if spell value difference is over 7 : then the chance of successful trades will decrease quite a lot as spells of different values get randomly chose more often than matching values.
July 8th, 2016, 10:00
(This post was last modified: July 8th, 2016, 10:18 by namad.)
Posts: 520
Threads: 8
Joined: Jul 2011
Oh wow, i never realized the ai was that smart.
Maybe they've had great trades possible and they've just hidden their goodies from me, by not showing them on their list of choices I can choose. Which lead me to assume they didn't have them at all.
edit:
Another option though is to just use human logic.
The reason they removed technology trading from civ5 (it was in civ4) was because it was too good for both parties involved. Even if player A trades with player B and player B gets a technology (spell) twice as good as player A... Player A still benefits more than player C or D or E or F who weren't involved at all. Now in these games any technology can go to any player, there are no realm restrictions, and no technologies not in a player spellbook.
I think that relaxing the trade conditions between the AI to +/-5 or 10 or whatever the number scale is, would be fine as long as you did like you said and reduced the frequency of positive interactions between AI's... I think all of that could be fine, IF you give the human player the same benefit, instead of the AI he trades with demanding to benefit from the trade, give the player the same +/-5 wiggle room. It's what would be given by a human opponent who was friendly to you in a 5 player 1v1v1v1v1 human pbem multiplayer game of civilization or MoO or whatever.
Maybe if the human player gets the bonus wiggle room it will help take the sting out of ai players trading with each other?
July 8th, 2016, 10:44
(This post was last modified: July 8th, 2016, 10:45 by Seravy.)
Posts: 10,463
Threads: 394
Joined: Aug 2015
Due to space constrains I'll go with - instead of reducing frequency - simply not trading if the selected spells are not in range to be valid. That way, depending on what spells they have, anywhere from half to 90% of the trades will fail since the randomly selected spells will not be in range. We can regulate the frequency by making the range tighter or wider.
The scale is simple, the first common spell is 11, the last very rare (40th spell) is 51, each spell is 1 more than the one before it.
Another +/-5 can be added to that based on the availability for research, and spells can have an up to +15 or -10 modifier if they are very good/useless for the AI.
So 1 tier is worth 10 and preferences can add or subtract 1 to 1.5 tiers.
Some examples - assuming the spell gets no modifier from being in/missing from research which can be +/-5:
Bless is 1st Life spell, no modifier , value =11
Holy Weapon is 4th Life spell, no modifier, value = 14
Healing is 5th Life spell, +15 modifier, value = 30
Heavenly Light is 6th, +10 modifier, value = 26
Guardian Spirit is 8th, no modifier, value = 18
True Sight is 11th, no modifier, value = 21
Resurrection is 13th, +10 modifier, value = 33
Prayer is 20th, +10 modifier, value = 40
Angel is 27th, no modifier, value = 37
Consecration is 35th, no modifier, value = 45
Life Force is 36th, +10 modifier, value = 56
Arch Angel is 39th, +15 modifier, value = 64
Armageddon, Time Stop are both 40th in their realm, with a +15 modifier, their value is the highest possible = 65
Earth Lore is 10th in its realm but has a -10 modifier (AI cannot use it), value = 10
Earth to Mud is 1st in nature and has a -5 modifier so value = 6 making it the lowest trade value spell.
In human trades, there are two cases.
If the human asks for trading, any spell pair where the spell the AI gets is equal or higher value is offered.
If the AI asks for the trade, based on relation, the human player can get up to 150% (best modifiers) value for their spells - or if the relation is bad, they might not even get the 100% value and get ripped off.
Posts: 520
Threads: 8
Joined: Jul 2011
Given that the current hope, I think, of your design for the AI is for the AI to try to win the game (not just be annoying to play against)....
I think the wiggle room should be granted to trades the human player asks the AI for. Even if the spell the human offers is 1or2 points worse than the spell the AI gives up that AI still benefits vastly compared to the other 3 AI. Ideally if there were room the AI would only do this if no other trades were valid between the human and AI, which is what a real human opponent would do, accept a slightly unfair trade if and only if it was the only trade that could be made (because any trade at all benefits them a lot). Then again maybe there is not even any room to give the human to AI trade the same wiggle room logic AI to AI trades have? if not, oh well, no big loss.
Posts: 10,463
Threads: 394
Joined: Aug 2015
(July 8th, 2016, 18:00)namad Wrote: Given that the current hope, I think, of your design for the AI is for the AI to try to win the game (not just be annoying to play against)....
I think the wiggle room should be granted to trades the human player asks the AI for. Even if the spell the human offers is 1or2 points worse than the spell the AI gives up that AI still benefits vastly compared to the other 3 AI. Ideally if there were room the AI would only do this if no other trades were valid between the human and AI, which is what a real human opponent would do, accept a slightly unfair trade if and only if it was the only trade that could be made (because any trade at all benefits them a lot). Then again maybe there is not even any room to give the human to AI trade the same wiggle room logic AI to AI trades have? if not, oh well, no big loss.
While the game does calculate a similar sum based on relation and other diplomatic factors as in trades the AI offers to the human, this number is then not used at all. Which is probably intentional and should not be changed, it's very likely they removed it from the game later for good reason.
There is a fundamental difference between AI to human and human to AI trades.
When the human player is trading, he selects both spells - as long as the values are not bad for the AI otherwise the option is not offered - while in trades the AI offers to them, the AI chooses the spell they want to get and the human only gets to decide what to give in exchange. So they can't say "I don't give you Spell Blast but I still want High Prayer so here, have Life Force instead". Nor can they cancel and see what better options they have. They either give up the Spell Blast for it, or don't trade if the AI asked for that.
Let's be reasonable, when the human player trades - unless they are stupid - they'll only ever offer spells that cannot be a threat to them. While it still might help the AI against other AI, that too benefits the player - one of their enemies gets stronger but another weakens - not to mention about half the spells only ever work against the human player, since they are combat spells : the AI cannot even cast them against another AI. The only way a trade can benefit the AI - other than the player being stupid and trading away something they cannot defeat - is if they trade for something on their research list, which allows them to skip it and research the next one faster which might actually help them - but since the AI prefers to trade for spells he doesn't have for research - which is the right decision if the human player is stupid enough to trade away something that makes a difference - the likelihood of traded spells speeding up their research is not that much. Trading for a spell that is not on your research list and you cannot use is no advantage, not even if the spell costs 5000 RP.
There is one other way the AI can benefit from a trade, if they trade that spell away with others later for something else. However, if they already had to offer something that was worth MORE, and AI trades will be restricted to near equal value, the chance of the AI getting something that's both useful and something they couldn't trade for using their existing spells is minimal.
Trading is more beneficial to the human player overall, regardless of spell value , because :
-They have brains and know which spell benefits them and the AI how much instead of looking at the numbers. No matter how well the numbers are set they are ultimately constants : The AI will value Prayer at 40 even if they already have High Prayer, and they'll want Summon Champion even if they have 6 heroes.
-They'll trade everyone regardless of relation levels : The AI will not trade with those they don't like, limiting their chance to speed up research enough to matter compared to how much the player can get.
-They benefit far more from spells of high rarity since those are usually specialized and they can use them better - the AI will still keep summoning Sky Drakes even if the human player has a way to counter them and slaughtered 20 using web and strong ground units, while the human player would start summoning other monsters after the loss of the first stack of sky drakes. Not that a smart human player ever loses sky drakes in battle in the first place.
-And the human player gets more trading chances per X turns than the AI on top of having more potential trading partners
Of course some of this is subjective - a bad player can benefit from "even" trades less than the AI - but I want to go with the assumption that the player will play well - If they don't then they are supposed to lower the difficulty level instead of relying on the AI being stupid.
By the way the AI to AI trading limit has been done and seems to function properly, the limit is currently set to 9 or lower difference in value. Did 3 tests, the AI never traded if one had only commons and the other very rares, they traded a lot when they both only had commons, and they traded less but still some when one had 10 commons and the other had 5 high end uncommons and 5 low end rares. (in all tests the two AI were allies to ensure they can trade with each other, and difficulty was impossible)
How much this influences gameplay will have to be found out the hard way, by playing and possibly losing to it if the trades end up still too much help to the AI.
Posts: 520
Threads: 8
Joined: Jul 2011
That's a good point, spells the ai literally cannot cast except against the human should probably be rated as worthless in human to ai trades (if you were going to add wiggle room, but I guess you're not.)
I guess there's a problem in that in master of magic not every technology/spell is useful, whereas in say civilization4 even a technology you have no use for is still going to be a useful pre-requirement for later on in the game at some point.
|