Page 1 of 1

EmotionAI

Posted: 11 Jun 2018 19:51
by zuma
HEY, everyone!

EmotionAI is my first attempt to create an AI that responds to an interaction
from other players.
AI in OpenTTD in general are pretty "dumb" in a way that if you start making
their existance hard, for example place a road blockade on a path, they will
do nothing about that and start loosing heavy money on that path.

So EmotionAI "scans" her paths and is looking for a intervention from other players,
if something like this is found she will make adjustments to that path (build a
workaround or so on).
EmotionAI checks if some player:
- destroyed a path
- tries to steel material from her stations
- tries to block her path
- destroyed a path in form of her depot

EmotionAI also has a mechanism to "attack back" the author of those things.
She has a model, in which she stores player's "karma" points and if they have low
enough makes an attack back.
Attack include:
- blocking players path with road blockade
- destroying his road tile in a path of his vehicles
- buys rights/advertisement/rebuilds roads in a players city
- surrounds his city with rails in order to stop the city growth

The building and money portion of the AI is from SimpleAI by Brumi.

Hope you like the AI, if interested leave a comment below. :)

Re: EmotionAI

Posted: 11 Jun 2018 20:13
by pelya
I never knew I needed GrieferAI.
Now my life is complete, as I can perfectly simulate network games while offline.
The only thing it lacks right now is some 'lol nub pwnd' chat messages.

Re: EmotionAI

Posted: 11 Jun 2018 20:31
by zuma
It's not exactly a GreferAI in the sense that it greefs you.
EmotionAI (the stat that it is right now) will only attack you if you really try to make a lot of damage to it.
Maybe for future work there can be implemented a setting which will determine the likelihood of an attack to other companies.

Re: EmotionAI

Posted: 11 Jun 2018 21:05
by pelya
Simply decrease the karma value each month for the nearest player., and it will be perfect high-challenge AI ;)

Re: EmotionAI

Posted: 13 Jun 2018 18:35
by Brumi
Wow, another fork of SimpleAI, I'm honored :)

I tried for a while, but I fail to see how she attacks other players. Did the classic destroy-trucks-with-trains thing, set Player::DEFAULT_KARMA_POINTS to 0, but still haven't seen an evil move... Of course, she builds another route around the level crossing when I destroy her trucks, so destroying the trucks is a bit tricky :)

Re: EmotionAI

Posted: 14 Jun 2018 23:17
by zuma
Brumi wrote:Wow, another fork of SimpleAI, I'm honored :)

I tried for a while, but I fail to see how she attacks other players. Did the classic destroy-trucks-with-trains thing, set Player::DEFAULT_KARMA_POINTS to 0, but still haven't seen an evil move... Of course, she builds another route around the level crossing when I destroy her trucks, so destroying the trucks is a bit tricky :)
I didn't implement the detection of destroying truck with trams, as it could be just a luck (not effect intentional from other player). Also it could be tricky to decide who did it (because only the event gets passed that your vehicle was destroyed, no inication where it was rammed).

If you want to see EmotionAI do some harm try to play agains her and just cassually build some routes, best if you build truck routes between cityes. Then make a train blockade on one of her routes or build a lot of stations around one of her stations. She will decite what to do with you (if you have more karma point she will just buy rights in your citys or advertize there, if you have low karma point she will make train blockade on your paths, build rails around your city, or a heliport in your city. "your city" means that you have a good reputation in the city). :)

I will try to implement more decisions in the future or maybe change the karma system.

Re: EmotionAI

Posted: 30 Jul 2018 08:56
by Zuu
zuma wrote:I didn't implement the detection of destroying truck with trams, as it could be just a luck (not effect intentional from other player). Also it could be tricky to decide who did it (because only the event gets passed that your vehicle was destroyed, no inication where it was rammed).
There is AIEventVehicleCrashed::GetCrashSite which should give you the tile where the vehicle crash occurred. But you still need to check ownership of nearby rail tiles to try to resolve a company to blame.

Re: EmotionAI

Posted: 17 Aug 2018 16:06
by xarick
EmotionAI crashes with a "too long to start" message on a 4096x4096 map.

Re: EmotionAI

Posted: 20 Sep 2019 15:58
by Wormnest
EmotionAI crashes: index 'HasStatue' does not exist.
Unnamed, 1981-09-25.png
(666.59 KiB) Not downloaded yet