Latest Posts

Topic: Difficulty levels

DragonAtma
Avatar
Topic Opener
Joined: 2014-09-14, 01:54
Posts: 351
Ranking
Tribe Member
Posted at: 2016-02-19, 07:54

So in another thread, I recommended that we add difficulty levels. At GunChleoc's request, I'm adding a new thread to discuss them.

I think that there should be handicaps for the AI. Fortunately, they'd be fairly easy to make:
* Novice(Very Hard): Production (not counting moving) takes 200% of normal time. Starting wares & soldiers are 50% of normal, rounded up.
* Easy(Hard): Production (not counting moving) takes 150% of normal time. Starting wares & soldiers are 67% of normal, rounded up.
* Normal(Normal): Identical to how it is now (and, presumably, the default).
* Hard(Easy): Production (not counting moving) takes 67% of normal time. Starting wares & soldiers are 150% of normal, rounded up.
* Very Hard(Very Easy): Production (not counting moving) takes 50% of normal time. Starting wares & soldiers are 200% of normal, rounded up.
* Insane(Cakewalk): Production (not counting moving) takes 33% of normal time. Starting wares & soldiers are 300% of normal, rounded up.

Why am I listing two names for difficulties? Because the second would be for the player. After all, assigning the top level to all the CPUs would be insane (especially if they're all allied), but only assigning it to the player would surely be a cakewalk! My only worry is that starting wares may be too tight on Novice(Very Hard), but I'm sure things can be fixed.

We can also discuss AI improvements later, but it should be a lot easier to add handicaps (plus they make it easier for a good player to play against an average player).

And it should be fairly easy to test it, too; after all, an Insane CPU vs a team of six Novice CPUs should be pretty equal; the only difference I see is that movement ("walk to trees", "walk back to hut", and so on) may give the team of six a slight advantage.


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2016-02-19, 12:30

I think that for AI starting wares should not change. Current AI sometimes has problem with lack of resource (in some maps, especially where is limitation of terrain). For human players - we should consider minimum number of wares. The line considering this idea can be realised by:

new_number_of_wares = max( standard_number_of_wares * difficulty_factor , minimum_number_of_wares )

where: difficulty_factor = {0.5, 0.67, 1, 1.5, 2, 3} for each difficulty type, stadnard_number_of_wares - number of wares currently implemented, minimum_number_of_wares - definit minimum of wares that should be considered.

Why I am thinking about it? Because on some maps, some positions has no gold at all. Or hardly any gold. Building up two ports in a very short time is the major aim for the player. Lack of gold can be very harmful then. Considering Empire, the tribe needs 4 gold bars to build 2 ports. And that is standard number of initial gold.

Other example is with Altanteans clothes. They need clothes to produce clothes. Initial number of wares is very limited too.


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

Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-02-19, 14:18

there was a thread about the topic. THere had been several threads, in fact, but I cannot find them; either they are older than I assume, or they started about a different argument and so I cannot see them by the title.

Anyway, the proposal to change working speed of the Ai to make difficulty levels is nothing new. I already was a strong proponent for it (I could go all hipster and say I wanted to have difficulty levels before it became mainstream :). The problem is that the programmers have limited time, and they didn't consider this enough of a priority. There has been an attempt to introduce difficulty levels by limiting the amount of certain buildings, in particular the smelting works and training sites. It has been introduced a few months back. I don't remember the specific numbers, but I think at very easy level the AI is limited to making one smelting works and no training camp/dungeon, and it can't make more than 2 at easy level.

This approach, I lamented, is very limited. First, you can't make difficulty levels harder than normal. But most important, the limitation is too rigid to adapt. In early game, the ai is the same as always; the limitation only means it cannot progress to late game. Then, the limitation on buildings does not take into account how much space is available; in a small map, the ai would never be able to make more than one smelting works anyway, so playing at easy or normal level is the same, but in a large map it would be possible to make a dozen smelting works, and the ai is thoroughly castrated by the small limitation.

Almost everyone agrees that the best way to make difficulty levels is to change the working time, but it apparently would require more coding (it seems a little thing to me, instead of "35 seconds" you write "35 * X seconds", where X is a parameter determined by the level, and you're done, but I'm not an expert of programming, and the code must be made in a way that this would not be easily implemented). So it hasn't been done yet. It is something on the "to do" list, but we should keep it for build 20.

By the way, I think the changes in the production time should be in the ai, not the human, so that managing one's tribe would be the same at all difficulty levels. And I agree with einstein, I would avoid giving less starting resources, as is some cases they are all needed; giving more is ok, though. Alternatively, the difficulty level could be set independently for every player.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2016-02-19, 15:12

Giving human or AI players more or less starting resources is pretty easy - we only need to add more scripts to the starting conditions, e.g. eg we could have Headquarters (easy), Headquarters (normal), Headquarters (challenging) etc.


Busy indexing nil values

Top Quote
PkK

Joined: 2012-01-06, 12:19
Posts: 236
Ranking
Widelands-Forum-Junkie
Posted at: 2016-02-19, 22:27

GunChleoc wrote:

Giving human or AI players more or less starting resources is pretty easy - we only need to add more scripts to the starting conditions, e.g. eg we could have Headquarters (easy), Headquarters (normal), Headquarters (challenging) etc.

I use these starting conditions for tougher AI players:

http://colecovision.eu/stuff/widelands-patches/

Instead of a one-time bonus they repeatedly give wares.

Philipp


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2016-02-20, 10:00

Thanks!

I have put them into a new branch so that we can play with them.


Busy indexing nil values

Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-02-20, 12:20

giving a fixed amount of resources every x time is better than static limits, but it also is a limited approach. First, it again has the problem of not differentiating between large and small maps; in a small map those wares are a lot, in a large map they are negligible compared to thoose that are available normally. And second, it is too undependent on the game situation; it does not matter how bad the ai situation is, it will always get those resources. while increasing the working speed will give a boost to the ai that is always related to how well the ai is actually faring, giving a ffixed bonus will make less important to expand, or destroy stuff.

But I agree that, until someone codes for cchanging the working speed, this would be better than nothing. At least we can introduce levels that are harder than normal that way.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2016-02-20, 12:45

wl.map.Map has width and height attributes that we can access from Lua, so we could use width * height as a scaling factor for the wares given. We could also add player_slots into the formula - the more players on a map, the less space each player has. So, width * height / player_slots.

Edited: 2016-02-20, 12:46

Busy indexing nil values

Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-02-20, 14:00

GunChleoc wrote:

wl.map.Map has width and height attributes that we can access from Lua, so we could use width * height as a scaling factor for the wares given. We could also add player_slots into the formula - the more players on a map, the less space each player has. So, width * height / player_slots.

is there a way to calculate the amount of buildable land? the algorithm for territorial lord already does count the walkable land. the best thing would be to count available buildspaces, but that's too complicated probably. So, calibrating the algorithm to the amount of walkable land divided by the number of players should work fine. the only limitation is for maps that include a lot of desert, but nothing is perfect, and it's already a large improvement over a bonus that scales only with map size - which by itself is an improvement over a bonus that doesn't scale at all.

Since we're here, I may also propose to scale the bonus with time, up to a certain amount. That's because the same amount of resources is more important in early game than in late game. Ideally, the resources gifted shall increase with the increasing of controlled terrain, up to a certain fixed amount once all the economy has been built. Say, a good equation could be X' = X * (t^2 / (10000 * L +t^2), where X' is the amount of resources given, X is the amount of resources that we want to give at time = infinity, and L is the area of walkable land divided by the amount of players. t is in milliseconds. So with that equation if every player has an area equal to 1000 (for comparison, the whole map of crossing the horizon has a walkable area around 10000) then after three hours the ai will get half the resources it will eventually get, and after six hours it will roughly stabilize (80% of infinity amount). At t = infinity, 10000 * L + t^2 is roughly equal to t^2, so X' = X. We could even make the bonus the ai get dependant on the amount of land it controls, if we want conquering the ai to have a meaningful impact on how much resources the ai will lose. I propose this needless complication now because it will be much easier to code if it is coded in from the start.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2016-02-20, 14:31

king_of_nowhere wrote:

is there a way to calculate the amount of buildable land? the algorithm for territorial lord already does count the walkable land. the best thing would be to count available buildspaces, but that's too complicated probably. So, calibrating the algorithm to the amount of walkable land divided by the number of players should work fine. the only limitation is for maps that include a lot of desert, but nothing is perfect, and it's already a large improvement over a bonus that scales only with map size - which by itself is an improvement over a bonus that doesn't scale at all.

I found this in infrastructure.lua:

plr:get_suitability(building, field)

So, if we feed this with a small building, we should be able to get all unoccupied buildable fields.


Busy indexing nil values

Top Quote