Return-To-The-Roots / s25client

Return To The Roots (Settlers II(R) Clone)
http://www.rttr.info
GNU General Public License v2.0
477 stars 75 forks source link

AI builds and destroys woodcutter #598

Open Flamefire opened 8 years ago

Flamefire commented 8 years ago

Looking at another problem I found that the AI builds a woodcutter, destroys it and rebuilds it multiple times.

Replay: https://github.com/Return-To-The-Roots/s25client/files/423522/2016-08-17_20-27-11.rpl.zip

Position: 20x138 (red player) from the start (skip forward to 300k and you'll see it)

ccing @jhkl

jhkl commented 8 years ago

I'm guessing a good place for a new woodcutter is searched, but there are no 'natural', reachable trees left. So the trees of the foresters are the only ones that create positive 'woodcutter space'. The existing woodcutters near the foresters have a negative influence, so the algorithm tries to place a new woodcutter as close as possible to the (few) trees, and as far as possible from the existing woodcutters. When the new woodcutter is finished, the few trees are already chopped down by the existing woodcutters -> no trees in range -> burn down.

Possible solution: Remove positive influence of all trees, that are already in range of another woodcutter, instead of making the woodcutter produce a negative influence. Might be problematic near foresters because two woodcutters are usually needed for one forester.

jhkl commented 8 years ago

Oh, it might be even worse, just found the following comment in AIPlayerJH.cpp, line 898 (method FindBestPosition()):

// TODO: this totally ignores existing buildings of the same type. It should not. Re-introduce the resource maps?

Flamefire commented 8 years ago

It is strange, that it rebuilds the woodcutter after burning it down. There should be some kind of hysteresis so it will keep the woodcutter a bit longer and rebuild a bit later. So the threshold is not that low, that it will fall enough as soon as the woodcutter is finished. Probably give it a bonus before destruction if a forester is close.

Maybe fixing the resource maps would already help...

vader1986 commented 7 years ago

I'd say a good woodcutter position is a position fulfilling at least one of those requirements: 1) many trees but no wood-cutter nearby 2) a forester with less than 2 wood-cutters nearby Also, there must be need for a woodcutter (ratio sawmill/woodcutters) in both cases.

Conditions for removing a wood-cutter, then would be (both must be fulfilled): 1) no forester nearby 2) no tree nearby

Does it make any sense? (i'm absolutely not the best player hehe)

Spikeone commented 7 years ago

I'd say a good woodcutter position is a position fulfilling at least one of those requirements: many trees but no wood-cutter nearby a forester with less than 2 wood-cutters nearby Also, there must be need for a woodcutter (ratio sawmill/woodcutters) in both cases.

Those cases are not considering the following:

just adding those

MarkL1961 commented 7 years ago

@vader1986 (I started watching this project recently and have played this recreation of the best version of settlers for a couple of years) Your comment makes perfect sense to me providing that you are checking for all foresters and woodcutters for all players nearby. My experience of the game is that a woodcutter and forester does not respect a players boundary. If another player next to a boundary has a forester and one woodcutter and neighbour can safely build another woodcutter. As per the comment from @Spikeone if I have understood it correctly, in the scenario I use the other player may be using the forester and one woodcutter to build up a thick forested area to make it harder for neighbours to expand their boundary. If they then build a second woodcutter yours is now redundant, but as a player you would keep it until all trees have gone before destroying it

Spikeone commented 7 years ago

@MarkL1961 Yes, thats what I ways trying to say, there are 2 types of woodcutters. Those for economy and those for tactics. I don't think the AI should use hostile foresters if those have only one woodcutter but they should counter single hostile foresters / hostile foresters with stopped woodcutters as a player would do. Those tactics aren't used that often but still the AI should react in a somehow good way. I also hate building a forester for one or two trees but sometimes those are blocking good spots or passages.

Also in most cases 1 big area for wood production is better than 3 smaller, I always build foresters and woocutters at one spot and use the surrounding area for production (sawmills, miller, bakery etc.) and areas further away for farmers. This leads to one problem: If I lose that area, I wont have any wood... but if that area is lost, the game is already lost so it doesn't matter.