Worker AI

For general chat that doesn't fit in any of the other forums below.
Post Reply
NoSpin
Warrior
Warrior
Posts: 81
Joined: Mon Aug 21, 2006 6:00 am

Worker AI

Post by NoSpin »

I am confused about how the AI works....

If i have more workers then assigned jobs what do the extra workers do? nothing? If I have a building that needs to be built and only one worker assigned but several extra workers with nothing else to do, will they help out or sit around and do nothing?

Lets say I have an inn with two workers assigned to it. The inn is full of wheat and has been full for several turns. Will those two workers be added to the idle workers count?

Brett
User avatar
Giszmo
Warrior
Warrior
Posts: 261
Joined: Sat Nov 26, 2005 10:23 pm
Location: Germany
Contact:

Post by Giszmo »

If i have more workers then assigned jobs what do the extra workers do? nothing?
yes.
If I have a building that needs to be built and only one worker assigned but several extra workers with nothing else to do, will they help out or sit around and do nothing?
the second.
Lets say I have an inn with two workers assigned to it. The inn is full of wheat and has been full for several turns. Will those two workers be added to the idle workers count?
yes.

Assume you have a swarm set to have 7 workers.
This swarm will request 7 workers until it has 17 wheat.
Now as only 3 ressources are missing to be full only 3*2=6 workers will continue to work there.
The 7th worker will get released. As soon as there are 20 wheat in the swarm it will release all its workers (0*2=0).

Until version 0.8.15 buildings requested as many units as have been assigned by the player as soon as one single ressource was missing.
In the case above 7 globs would go and fetch the last missing wheat.
With better estimators on the success of ressource-delivery i guess we will be able to drop this number of workers to 1.1 workers per missing ressource.
This estimator would have to take into account how hungry/hurt the worker is, how crowded the path will be and if it will get attacked.
On the long term i hope we can get rid of the unit count per building at all.

Giszmo
NoSpin
Warrior
Warrior
Posts: 81
Joined: Mon Aug 21, 2006 6:00 am

Post by NoSpin »

Thanks
quinnteh
Explorer
Explorer
Posts: 36
Joined: Fri Jul 18, 2008 7:32 pm
Location: Melbourne, Australia

Re: Worker AI

Post by quinnteh »

I am actually planning to use Glob2 as a testbed for my project in uni, which is about game AI. And this worker allocation problem seems to fit the description of the general problem I am trying to solve exactly. I'm trying to come up with a mechanism that will allow more efficient allocation of workers to available tasks, and if it works can be used in other applications (mostly other RTS games) as well.

Anyway, can anybody tell me how to become a developer or who to contact to talk about this with?
K776
Warrior
Warrior
Posts: 61
Joined: Sat Nov 26, 2005 10:23 pm
Location: New Zealand
Contact:

Re: Worker AI

Post by K776 »

quinnteh, thanks for your interest. Please refer to the private message I have sent to you. It details some steps to get started.
User avatar
Giszmo
Warrior
Warrior
Posts: 261
Joined: Sat Nov 26, 2005 10:23 pm
Location: Germany
Contact:

Re: Worker AI

Post by Giszmo »

hi quinnteh

as i have implemented a unit allocation system that in my eyes (i studied maths) is far better than the existing i would be interested in talking to you.
the theory now:
1. if a unit that has the suiting resource on hands can reach the building needing it, take this.
2. if a unit with no res can reach the res and the building afterwards, take this
3 if none of the above aplies, take a free unit that has the wrong res at hands

my theory:
1. assign a score to each unit taking into account distance to res, distance to building, res at hands swimming ability, building ability, walk speed, hunger and hurt level.
2. choose top score
(details like penalty for swimmers and over educated units i can give in a chat)

my implementation:
unfortunately my implementation had bugs:
* not fireing the extra units not needed anymore.
* requesting only one res at a time so units would drop the other res that was needed, too to get the other res for a building needing both
players complained that resources were wasted too much (a glob with wood at hands standing right between an inn and wheat fetched the wheat if it was free) what was by design in most cases.

my implementation resulted in 10% faster building at the cost of some wasted resources and many confused players in my test scenario. as i had no time fixing the bugs and modifying the bias towards not wasting resources we dropped the code for now. it is still in but commented out.
see http://hg.globulation2.org/glob2/file/2 ... ilding.cpp line 1388 and 1417.

contact my via leo.wanderslebägmx.de

i'd love to see this part getting improved.

Greetings, Giszmo
Post Reply