[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[glob2-devel] New unit allocation system almost done

From: Bradley Arsenault
Subject: [glob2-devel] New unit allocation system almost done
Date: Mon, 19 Mar 2007 21:26:10 -0400

Although I haven't had much time recently, I have found some time to
work on the new unit allocation system, and its coming along nicely.
After powering through some fustrating bugs, I managed to come out
with a working system without rewriting the unit code.

And I've commit this new code tonight. It is still technically beta,
and their are probably lots of lingering bugs that need to be
resolved. And how the buildings are prioritized is also incomplete.
Currently, it prioritized inns over other buildings, and uses the
percent of needed units to compare otherwise. Feel free to offer
opponion regarding how buildings should be prioritized.

Even though this system is very simple, the advantages of the new
system are obvious. All buildings needing units seem to be full, and
upgrade centers like Racetracks and SwimmingPools equally so. The new
system seems to be cranking out more effort out of the same number of

This system is also very flexible. If we wanted to add a user chosen
priorities, like low medium and high, it would be as simple as coding
it in the GUI, and changing the priority function to take these into
account. The GUI would be the hard part.

You can test the system yourself, it is fully functioning, and I've
commit it to the cvs. While the code isn't encapsulated and documented
quite yet, I am working on making sure that the new code can be
maintained by all.

I should have a complete version within a couple of days. Please point
out anything out of the ordinary, any bugs you see, and make any
comments on how the system should prioritize buildings or choose units
etc... Also, it seems like I didn't modify any loading and saving code
(except add one variable to Unit, which is delt with), so technically
the system should be backwards compatible with old saves and maps.

Here is a quick summary of how it works:

1) Buildings that need units subscribe to a one global call list,
which is maintained in a sorted order
2) When a building has enough units, it calls updateCallLists which
will remove it from this call list, and it will no longer be given the
oppportunity to hire units.
3) Any buildings on the call list are given the oppurtoninty to hire
units. They choose units that are closer, and have the ressource they
want first, and then units that have no ressource second, and units
that have an unwanted ressource third. This is also fairly simple, but
highly effective.
4) Flags operate the same way, they are on the same call list and are
prioritized with the other buildings.
5) Units that aren't hired by a building wait 32 ticks for a job, then
head to a racetrack/swimmingpool/school to upgrade, because if they
aren't hired, that means that they couldn't have been hired. 32 ticks
is just over a second, it doesn't take units long to decide what they
should be doing.

Really. I'm not lieing. Bradley Arsenault.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]