Latest Posts

Topic: Probability Drive

toptopple
Avatar
Topic Opener
Joined: 2013-10-30, 08:11
Posts: 156
Ranking
At home in WL-forums
Posted at: 2016-05-27, 09:03

I want to get rid of an idea concerning the foresters and perhaps also the geologists. The idea is to introduce probability to the choice of work targets. This goes like this;

The forester has an area of the map to work on and the walk distance to his next target location can be measured, e.g. from 1 to 10. The choice for the next target is taken randomly. But, and this would be new, the choice undergoes a dropping probability. When dropping occurs, a new choice is selected (randomly). The drop probability is a value associated with the target or walking distance, and e.g. may range from 0 at distance 1 until 70 at maximum distance.

The proposed measures make the work behaviour of those workers who have to select a target location appear more natural. It also makes more sense in gameplay as the result of a worker's work (e.g. geologist) is more predictable. In my eyes this clearly improves the game and seems not very difficult to implement. Cheers!


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2433
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2016-05-27, 19:59

Sorry, but i don't understand what your proposing. What do you mean with:

The proposed measures make the work behaviour of those workers who have to select a target location appear more natural.

Why is it now unnatural? The only thing i am stumbled of these days is that the geologist doesn't look for resources in the closest spots nearby the flag where he starts to search for resources.


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
toptopple
Avatar
Topic Opener
Joined: 2013-10-30, 08:11
Posts: 156
Ranking
At home in WL-forums
Posted at: 2016-05-27, 23:37

Ok, I have to explain face-wink.png The result of my proposed changes were, plainly expressed, that the worker under the probability profile would more often choose locations near his hut or staring location than those very far away. "Natural" because no reasonable worker would run from one end of the field to the other for each step to take, self-understanding, but take the nearer locations next.

One of the effects is that work is done more efficiently, so through-put is rising for the forester, e.g., also for the the geologist. Second effect is that work results of these workers starts forming a shape, namely concentric circles. How strong this effect comes to life depends on how "steep" or "flat" the probability profile is set. With the work forming a shape it is, e.g., less expensive for the player to put a forester in a corner which is nearer to a mountain.

Try it out an see if you like it! face-wink.png


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-05-28, 10:51

I know that the algorithm should be random, but i often see foresters surrounded by trees, with less trees at higher distances. I wonder if some snag in the code is already creating a similar effect, or if it is only a mix of coincidence and confirmation bias on my part.

But really, the difference should be small enough to be virtually unnoticeable.


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

I noticed this with the geologists too - it would ineed be nice of closer spots had a higher probability to be targeted by a worker than sports further away.


Busy indexing nil values

Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2016-05-29, 21:17

Mathematically, if picking random spot within radius r, average of all spots within that radius is about 0.7r. I mean half of them is closer then 0.7r, and second half is farer than 0.7r. Am I right?


Top Quote
DragonAtma
Avatar
Joined: 2014-09-14, 01:54
Posts: 351
Ranking
Tribe Member
Posted at: 2016-05-30, 00:55

Area of a circle is pi*r*r.

A circle with radius 10 would have area 100pi.
A circle with radius 7 would have area 49pi.

So yeah, about half the points in a circle of radius r would be within .7r. Technically the cutoff would be sqrt(2)/2 -- which means about .7071r -- but .7r is fine.


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-05-30, 01:50

works with a circle, not sure about a hexagonal grid. let's try to calculate:

  • at radius 0 there is only 1 corner
  • radius 1, 6 corners
  • radius 2, 12 corners
  • radius 3, 18 corners

ok, it's radius * 3. A circle of radius 10 would have a total of 1 + 1 * 6 + 2 * 6 + 3 * 6 + ... + 10 * 6 = 1 + (55 * 6) = 331 corners. Those outside a radius of 7 are (10 + 9 + face-glasses.png * 6 = 27 * 6 = 162. Yeah, it does work pretty well even if an hexagonal grid has not the same properties of the geometrical plane. So with a random picking half the times the worker will to to a field in the 30% more distant area.

Suppose we decrease the chance of being picked by 10% for every step away - but never lower than 0.1 to avoid problems with 0 probability.

  • radius 0: there is the building there.
  • radius 1: P = 6 * 0.9 = 5.4
  • radius 2: P = 12 * 0.8 = 9.6
  • radius 3: P = 18 * 0.7 = 12.6
  • radius 4: P = 24 * 0.6 = 14.4
  • radius 5: P = 30 * 0.5 = 15
  • radius 6: P = 36 * 0.4 = 14.4
  • radius 7: P = 42 * 0.3 = 12.6
  • radius 8: P = 48 * 0.2 = 9.6
  • radius 9: P = 54 * 0.1 = 5.4
  • radius 10: P = 60 * 0.1 = 6

Nice inversion of numbers we have there, but i see that every radius between 2 and 7 has a very similar probability. Could be good.

EDIT: or maybe it would be simpler to have the worker first pick a radius, then pick a spot with that radius, so all radii would have equivalent probability of being picked.

Edited: 2016-05-30, 01:53

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

2 notes:

  1. Different workers have different radii, so we need a general formula
  2. For efficiency, I suggest a 2-step search: Pick a radius according to probability, and if there is no spot found, try again with the full radius.

Busy indexing nil values

Top Quote
toptopple
Avatar
Topic Opener
Joined: 2013-10-30, 08:11
Posts: 156
Ranking
At home in WL-forums
Posted at: 2016-05-30, 17:19

Algorithmical, I suggest to keep what is already there - if it is any good - and only plant the dropping mechanism on top. So it's more easy to do a negative work here instead of a positive face-wink.png How a dropping probability translates into a selection probability, I don't know. But I think practice will do the better job anyhow in setting up the values.

You have to keep in mind that the "full house" problem must be avoided, i.e. in case there is no working slot available at all, the algorithm must fade. If the dropping is placed on top of the primary selection, this problem should be done already. For security you could run a loop counter and break the procedure when hit a limit.

Nice table of P-values there! For distances 1 and 2 the dropping probability could be 0 (which means the selection maintained 100%). This adds a bit to their stance. Cheers!


Top Quote