EmotionAI

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
zuma
Engineer
Engineer
Posts: 3
Joined: 11 Jun 2018 19:48

EmotionAI

Post 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. :)
pelya
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 18 Nov 2010 19:48
Contact:

Re: EmotionAI

Post 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.
zuma
Engineer
Engineer
Posts: 3
Joined: 11 Jun 2018 19:48

Re: EmotionAI

Post 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.
pelya
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 18 Nov 2010 19:48
Contact:

Re: EmotionAI

Post by pelya »

Simply decrease the karma value each month for the nearest player., and it will be perfect high-challenge AI ;)
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: EmotionAI

Post 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 :)
zuma
Engineer
Engineer
Posts: 3
Joined: 11 Jun 2018 19:48

Re: EmotionAI

Post 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.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: EmotionAI

Post 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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
xarick
Transport Coordinator
Transport Coordinator
Posts: 335
Joined: 26 Feb 2015 00:52

Re: EmotionAI

Post by xarick »

EmotionAI crashes with a "too long to start" message on a 4096x4096 map.
Attachments
Unnamed, 1950-01-02#4.png
(104.67 KiB) Not downloaded yet
Formerly known as Samu
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: EmotionAI

Post by Wormnest »

EmotionAI crashes: index 'HasStatue' does not exist.
Unnamed, 1981-09-25.png
(666.59 KiB) Not downloaded yet
Attachments
EmotionAI crash, 1981-09-25.sav
(578.71 KiB) Downloaded 137 times
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests