Latest Posts

Topic: News about AI

Nordfriese
Avatar
Joined: 2017-01-17, 17:07
Posts: 1954
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2017-05-31, 20:07

My list for Barbarians is: Wood hardener, Fernery, Lime kiln, Smelting works, 2×Metal workshop, Well, Tavern, Hunter, Gamekeeper, Barracks. Don´t forget that I added 1 Ranger and 1 Lumberjack to every tribe´s BE (including your presets).

About finishing the enemy: When the victorious player was conquering his first victim, he built lots of towers at the frontier whenever he couldn´t see his next target. He built nothing near the frontier of the almost-defeated last player. Also, I noticed that AI sends all soldiers to the front where it is attacking at the moment – it is aware all the time of another enemy at its border somewhere else, but the buildings are guarded by only 1 soldier, leaving it vulnerable. Perhaps AI should be taught not to leave a quiet front line unprotected.

If AI waits until a trainingsite is full, this means that effectively no training takes place, ever. At least in the games I watched.

I´m glad I could help! When further testing is needed, just ask.


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-05-31, 20:41

militarysites are build based on free teritory nearby, number of enemy militarysites nearby and resources like mountains nearby, also own nearby militarysites are considered - this is complicated and completely controlled by genetic algorithm. Also note that fitness function is mostly land size. So AI can just decide it is not worth to finish the enemy, but focuses elsewhere. It does not even understand the concept of "finish an enemy". If it was possible to get number of "wiped out enemies" from game's statistics I would include it into fitness function. But the game does not provide that. But I agree this is suboptimal. Or if there was info about "conquered land" - as a land that belonged to some other player before - this could go to fitness function as well...

For each militarysite AI tests accesibility of enemy (I am not sure now whether land or must be militarysite), if not accessible it might be dismantled, or capacity set to 1. But there still can be an error in code...

Anyway thanks for comments I will try to investigate and address them


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-05-31, 20:53

I updated the barbarians init.lua files:

barracks/init.lua:      is_basic = 1,
gamekeepers_hut/init.lua:      is_basic = 1
hunters_hut/init.lua:      is_basic = 1
lime_kiln/init.lua:      is_basic = 1
lumberjacks_hut/init.lua:      is_basic = 1,
metal_workshop/init.lua:      is_basic = 2,
rangers_hut/init.lua:      is_basic = 1
reed_yard/init.lua:      is_basic = 1,
smelting_works/init.lua:      is_basic = 1,
tavern/init.lua:      is_basic = 1
well/init.lua:      is_basic = 1
wood_hardener/init.lua:      is_basic = 1,

I hope this is correct. It will be pushed with next revision

I also removed few forced_after, prohibited_till flags - though I am not sure if it was good move...


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2017-05-31, 22:10

Tibor wrote:

Basic economy is really intended as a starter, ideally for first 30 minutes. If it takes more than hour - this is not good. If you add ranger (or similar) to the list it will not make big difference, unless you add something like <ranger:20>.

Why not? I think that being on the list with the number means for the buildings, that there will no be more buildings of this type than this number (before the basic economy is completed or cancelled). So if just one ranger is on the list, it should be a huge difference to "no ranger on the list".

Nordfriese wrote:

Hello, I´m back with a large number of test results! I tested a lot of games, but I did not store the number or even the individual statistics – only average values for each list and map.

Cool

First some comments on AI in general (I do not mean to offend, even if the AI may seem stupid now):

  • As long as the basic economy is not established, AI builds only buildings belonging the the basic economy (but lots of them). Someone was worried that a target of 1 ranger would lead to having just 1: No need to worry. AI will soon have 10.

Isn't this a huge bug?

  • After the basic economy is finished, all metal workshops are upgraded and no new ones are built. Tool production isn´t perfect.

face-grin.png

I did not test Autocrat games, as they take so long. I only used Collectors.

But it should be an AI for autocrat, right? Collectors is sooo different... Especially if there is no way to attack...

(...)

In other words: Tibor´s presets are the best suggestion for Empire and Atlanteans. My lists are best for Barbarians. WorldSaviour´s lists are also good, but not the best for any tribe.

Come on, the concept "basic economy" didn't work like it should ;-) But if you would like to test again with my lists, I would appreciate if you delete the mines... (bar: coal+iron, emp: marble, atl: none)

Tibor wrote:

  • Yes, AI builds too many trainingsites, this has to be manually finetuned.

Are you sure? The current algorithm requires a lot of them to be optimal...

  • A traininsite waits till it is stocked and then sets its capacity to 1. Untill then ... 0.

That is not the worst approximation to the perfect use of the trainings sites, but like I said, it requires a higher number of them to be as good as with perfect use...

A special case is the imperial arena: This algorithm isn't really needed, and a maximum capacity of 1 is suboptimal. It should be a little bit higher.

Also note that fitness function is mostly land size. So AI can just decide it is not worth to finish the enemy, but focuses elsewhere. It does not even understand the concept of "finish an enemy". If it was possible to get number of "wiped out enemies" from game's statistics I would include it into fitness function. But the game does not provide that. But I agree this is suboptimal. Or if there was info about "conquered land" - as a land that belonged to some other player before - this could go to fitness function as well...

Maybe the statistic "number of conquered military buildings" is not the worst approximation to this face-wink.png


Wanted to save the world, then I got widetracked

Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-06-01, 06:56

Small huts especially the ones dependant on reasources in vicinity have different "code path" so the basic economy does not apply to them out-of-box. Consider rangers. The teritery can be full of trees or a desert without trees. Therefore this is bad idea to hardcode the number of rangers, even if for first 30 minutes.

Similarly quarries. Lumberjacks as well.

On the other side, ANY productionsite is scratched from the list when finished. So basic economy target works as bottom limit for these small huts.

Do we have "number of conquered military buildings" available? Even better would be "number of destroyed sites".


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2017-06-01, 17:27

We have something like that in the general statistics I think - I don't remember right now if it's for soldiers or buildings though.


Busy indexing nil values

Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-06-01, 19:08

GunChleoc wrote:

We have something like that in the general statistics I think - I don't remember right now if it's for soldiers or buildings though.

Indeed. But this still does not address the issue. If there is a player with 1 remaining militarysite - there is no incentive to attack just that one and not another one of another player.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 17:07
Posts: 1954
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2017-06-01, 19:31

Perhaps you could implement something like this:

AI has an array of attack factors long attackFactor[nbEnemies]. Every time a militarysite belonging to enemy X is conquered/destroyed, attackFactor[X]+=increase. When AI decides which site to attack or whether to attack a building belonging to X, attackFactor[X] is taken into account.

The more buildings have already been conquered from a player, the happier the AI is to attack him again and therefore to finish him.

Genetic algorithm mutations could tweak the value increase to generate more or less offensive AIs.


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-06-01, 19:41

In fact, the relative strength enemy/we is considered when attacking, but it seems to me that problem happens before - when new militarysites are built.

If you have to build a militarysite in area with 1 enemy militarysites or 5 ones, AI will logically pick the second alternative...

I created new data in AI - number of destroyed warehouses, and they are well scored (rewarded). I will see what it will do.


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2017-06-01, 20:59

Tibor wrote:

I created new data in AI - number of destroyed warehouses, and they are well scored (rewarded). I will see what it will do.

This might be very good. And maybe ports and HQs should also count as "warehouses"

Tibor wrote:

GunChleoc wrote:

We have something like that in the general statistics I think - I don't remember right now if it's for soldiers or buildings though.

Indeed. But this still does not address the issue. If there is a player with 1 remaining militarysite - there is no incentive to attack just that one and not another one of another player.

Well, it's the best in statistics which I could find. "Wares" are also a good indicator for defeating - but the wares of the opponent. And this would be too complicated, I guess.

Tibor wrote:

Small huts especially the ones dependant on reasources in vicinity have different "code path" so the basic economy does not apply to them out-of-box.

This are good news

Consider rangers. The teritery can be full of trees or a desert without trees. Therefore this is bad idea to hardcode the number of rangers, even if for first 30 minutes.

That's what I mean with "the wood economy is too map-dependant" face-wink.png


Wanted to save the world, then I got widetracked

Top Quote