Topic: AI enhancement suggestion - wood

Tibor

Topic Opener
Joined: 2009-03-23, 23:24 UTC+1.0
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-01-25, 23:03 UTC+1.0

Hi,

I have an idea how to improve the AI, it relates to wood and ranger's huts. In fact I have two ideas:

  1. To test how many wood an AI player has on stock and if a treshold (f.e. 200 pieces) is exceeded stop all rangers huts. The second treshold like 100 pcs (if actual amount is lower then this number) would resume rangers huts.

  2. The second frequent problem can be too many trees and AI is too stupid to clean them up to make a room to advance. Also AFAIK, the AI algorithm will not build new cutter huts when there is enough wood on stock. This is not a good practice. Of course, generally it is, but trees/woods should have other algorithm - 'cut all trees' therefore it should build new cutters huts reguralry if there are trees in the locality

Also from lua scripting perspective, is there an call to stop/resume a building?

Tibor


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-01-26, 01:34 UTC+1.0

To point 1.:

Some of the maps have need to have more than 200 trunks in stock. They just need to be burned into the coal. So that the stock is not a good reference. Better are flows of stock (how many we are producing and how many we spend). Worse problem is to count how many trunks we need to deal with the economy? Based on map size, amount of coal, green place size and size of country.

But the idea is good face-smile.png It can be simply advanced into real controller or something like that face-wink.png

To point 2:

If you do so, the woodcutters will be placed everywhere around ranger's huts. That is not good. That is the worse you can do. The algorithm should take account existing woodcutters (and their production)! So if there is a woodcutter with 100% and still some trees, then you have a permission to build a woodcutter. If there are no woodcuters, then build one.


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
Mars

Joined: 2009-03-28, 10:26 UTC+1.0
Posts: 118
Ranking
Likes to be here
Location: Germany
Posted at: 2014-01-26, 21:32 UTC+1.0

I am not sure how it works at the moment but for me it would also be ok if the AI 'cheats' and knows the whole map (at least for resources like coal). As a human one can have the same information before playing the map, so the AI could determine if it needs to burn coal from wood or if there is a mountain with coal nearby.


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 23:24 UTC+1.0
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-01-26, 22:09 UTC+1.0

Mars,

coal buring can work on tresholds as well



if coal_on_stock>300 burning==going then
stop_burning_wood
if coal_on_stock<100 and burrning==stopped then
resume_burning_wood

I dont think a cheating is needed here....


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-01-26, 23:10 UTC+1.0

Tibor, but this works only with existing whole economy. At the beggining computer should know whether it have to build lots of woodcutters and coalburner or not.

Mars have a good idea of that. Now computer cheats too. It knows what resources are in the mountains (I've never seen sending geologists into the mountains by AI).

It is very complex problem. Some solutions have a feedback some not. Mars' idea had no feedback, and it is very complex: how can we decide what is on the map? It's not easy problem.

Tibor have a feedback and whole idea is based on it. But it is not simple to build a good controller (sometimes your economy needs more coal, sometimes less).


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 23:24 UTC+1.0
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-01-26, 23:52 UTC+1.0

Well, I am not suggesting a brand new AI, just additon to existing one. So building and destroying of buildings would be done as now. I dont know how exactly AI works now but I hope my suggestion would not interfere with current algorithm in a bad way. And I believe it could be very trivial to implement.

Of course, if I had to suggest the new AI from scratch, I would have another ideas...

Right now, I want to address very specific problem - AI after some time begins to stagnate - especially when no enemy is in sight... and I believe one of reasons are trees in a way and AI is to stupid to cut them and clean up the space.


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-01-27, 00:47 UTC+1.0

In my opinnion we should begin the discussion on brand new AI. It is very hard to implement it, but if we solve problems of AI from math side, the implementation would be much more easier.

And it is very hard to discuss all the things in one thread on this forum.

Some of the ideas are already written here (just search the forum), but the discussion are not simple (to write and to read).


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
SirVer

Joined: 2009-02-19, 15:18 UTC+1.0
Posts: 1442
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2014-01-27, 06:26 UTC+1.0

I am following this thread. The current AI implementation is done in c++ and is more or less a set of rules like the one tibor suggested in the op. As far as I understand the literature this is also what works best in general for AIs for specific games. There are obviously some rules missing - for example tibor is right that trees are a big problem for the AI (one solution would be to kill the tree life cycle for that - it would make it less likely for the AI to get stuck).

But back to the questions:

Also from lua scripting perspective, is there an call to stop/resume a building?

No, this is currently not implemented, but can be done very quickly and easily - however we are in feature freeze for b18 (still) so we can not do it in trunk. If you want to I can add this into one of the branches that will be merged after b18, but you need to build Widelands yourself for now.

In my opinnion we should begin the discussion on brand new AI.

The biggest issue with the current AI is that its code is a total mess. It is very hard to understand what it is doing and it is really hard to change behavior in an easy fashion. For example a rule based AI should be understandable by looking at each individual rules independently as they should not influence each other, but right now everything is one big if/else case.


Top Quote
teppo

Joined: 2012-01-30, 09:42 UTC+1.0
Posts: 425
Ranking
Tribe Member
Posted at: 2014-01-27, 08:25 UTC+1.0

The biggest issue with the current AI is that its code is a total mess.

I am somewhat interested, too.

Is there anything preventing many AI's in parallel? If the current is a mess, we could develop new one(s) and keep the old as it is. This way there would be no need to be afraid of false starts.


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01 UTC+2.0
Posts: 1116
Ranking
One Elder of Players
Location: Poland
Posted at: 2014-01-27, 18:17 UTC+1.0

teppo wrote:

The biggest issue with the current AI is that its code is a total mess.

(...) we could develop new one(s) and keep the old as it is. This way there would be no need to be afraid of false starts.

This is a very good idea!

But I have a question: is it possible to make a part of forum created only for AI threads? It can be a subforum of existing one. It would be much easier to create completely new threads only for completely new ideas. For example I try to make a simple math model of wood-economy (to bring everything into short equations), so I don't want to create every idea into new thread and create mess here, on the forum.

Small off-toppic:

Also in the game shold be something changed with the AI players. Maybe add "AI method"?

In other game (Age Of Empires II with unofficial extras) you can choose the AI method (standard AI, barbarian, hordes,... ; difference only with the power and inteligence) and the level (standard, easiest, moderate, hard). I can imagine that we can choose AI method as drop-down list (none, old AI, new AI) and it's strength (defensive, normal, offensive) like now. Then we can produce more AI-methods, dedicated to different map types (big, small, islands, continent with islands, etc.).


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote