[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [glob2-devel] Optimal Unit Assignment
From: |
Leo Wandersleb |
Subject: |
Re: [glob2-devel] Optimal Unit Assignment |
Date: |
Thu, 08 May 2008 01:08:50 +0200 |
User-agent: |
Mozilla-Thunderbird 2.0.0.12 (X11/20080420) |
Bradley Arsenault wrote:
The optimal assignment system is single task based, where a single task
is carrying a single-resource. Basically, we develop exactly what a unit
is going to do, carry a single resource (or other possible tasks), and
calculate the exact distance it will cover to do that task. If its
carrying a resource, this is just distance to the building, if its not,
it calculates distance to resource, and from that spot, distance to
building. Its important that the algorithms and gradients we use here
are the same as the ones the unit will actually use to determine its
path. Time is the only factor affecting efficiency, and distance is the
major factor affecting time (we could take walking/swimming speed, and
even harvest speed into account if we wanted to).
did you ever look into my unit allocation system? it does take into account
walk/swim/harvest speed. the comment says it all:
/* To choose a good unit, we get a composition of things:
1-the closer the unit is, the better it is.
2-the less the unit is hungry, the better it is.
3-if the unit has a needed ressource, this is better.
4-if the unit has a not needed ressource, this is worse.
5-if the unit has not a needed ressource and is close to a needed one, this is
better
score=
(hasRightRes*100/d
+hasNoRes*80/(d+dr)
+wrongRes*25/(d+dr))/walk
+sign(timeleft>>2 - (d+dr))*500
+100/harvest
*/
int r; //carriedressource
int noRes; //1 if unit has no ressource
int rightRes; //1 if unit is carrying the right ressource
int wrongRes; //1 if unit is not carrying the right but another
ressource
int distBuilding; //distance to the building
int distResource; //distance to the ressource
Map * map;
int penaltyWalk; //value depending on the distance to walk and the walk
speed
int penaltyLoosingResource;//value of not loosing the wrong ressource
carried
int penaltyHarvest; //the faster the unit can harvest the better it is
int penaltySwim;//swimmers are shifted down in score so they are free for
swimmer-only jobs. Maybe free slots in pools should be taken into account so all
can learn to swim.
To be truly optimal:
We then consider all buildings, all building unit combinations, and find
the one that fills all possible slots that ends up with the lowest
overall distance covered. This could be run as often as wanted to take
care of changing circumstances.
i guess we will always need a heuristic. if there are many free globs our
present heuristics are both acceptable while i'm sure the above mentioned one is
better.
if there are no free workers we must switch roles: workers choose among free
tasks.
hopefully i will