This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Thought process of a colonizer


After reading James's e-mail, I've been trying to think of a way that
the same "Colonizing" plan could work for both terrestrial and space
games, and I came up with the following thought process that the AI
should probably use.

(For clarity, I'll assume that the unit that the colonizer will build is
a city.  Footnotes for each section appear underneath that section.  I
also assume that if any value referred to is undefined, it will appear
to the algorithm as a zero.)

--- BEGIN MECHANICAL THOUGHT PROCESS ---

1. Consider the terrain around the colonizer.  It should consider every
tile that is known to the side, regardless of where it is (more on where
it is later).
1a. If the known terrain does not include a radius that equals of
exceeds that of the unit that the colonizer will build (e.g. terrain
around colonizer is known 2x2, but reach of a city is 3x3), call
subroutine A.  Otherwise, go to step 1b.
1b. Evaluate every known cell for its value to a city.  Call function B
to determine the value.
2. Given the reach of the city, determine the ideal spot(s) for a city. 
To do so, process each known tile, and add the scores of those tiles
that would be in a city's reach if built there (use different data
tables so that nothing weird happens).  The ideal spot to build should
be the tile that gets the highest score by this test.
3. Scan through the list of possible spots to build, and delete any
options that match any condition in function C.
3a. If no spots remain in the list, call subroutine A (i.e. explore
farther), then go back to step 2.
4. Multiply the score of each tile by s/(d+1), where s is the speed of
the colonizer (i.e. how many tiles it can traverse in 1 turn), and d is
the distance from the colonizer to that spot.*
5. The tile with the highest score is the one that should be settled. 
If there are no problems with that spot (e.g. it's already occupied by
an enemy city), go for it!  Otherwise, go to step 5a.
5a. If, for some reason, it can't be settled, pick the next-best spot
and try for that one.  If necessary, keep going down the list until an
open one is found.

* This penalty for distance may be too steep.  The formula might need a
few constants attached in order to make more distant spots less
undesirable.


A. 
1. If it is possible to order a nearby non-colonizer to explore the edge
of the known map and thereby gather the necessary information to
determine the area's value as a spot to build, do so.  Otherwise the
colonizer should do the exploration itself.*

*    Perhaps Brownian motion would be more appropriate as part of the
"Exploratory" plan than as part of the "Colonizing" plan?


B.
The properties of the tile should be considered as follows:
1. Look at the unit-consumption-per-size of the city.  Assign each
material listed 1 point for each unit needed per size.
2. Look at the unit-consumption-to-grow of the city.
Assign each material listed 0.5 points for each unit needed to grow.*
3. Look at the unit-consumption-per-cp of every unit that the city will
be able to build.  Assign each material listed 0.1 points for each unit
needed for each CP for each unit, then divide by the unit's CP.  Add the
final result to the tile's score.
(might need a few more tests in here)
4. Re-evaluate from step 1 using what-if conditions based on the city's
possible facilities.  An example of such a condition to evaluate might
be "What if I had a granary?".  These conditions should not be mutually
exclusive (e.g. allow "What if I had a granary AND a university?"). 
Multiply the result point value of each test by 1/x (where x is the
number of what-if's processed), and add the final result to the total
score.**
5. Return the final score as the value of the tile.

*   Maybe instead of using 0.5 or some other constant, the value should
use some kind of decay curve so that initial growth is more important
than later growth.
** This may be the key to writing a better "Improving" plan!


C.
1. Is the area clear of cities whose reach overlap that of a possible
city in this spot (i.e. would any other cities would try to use the same
terrain as ours)?*
1. Look at the materials that are listed in the city's base-consumption
and consumption-per-size.  Also, if necessary, consider the materials
that are in the city's base-production (adjusted for productivity, if
necessary).  Can the spot in question produce those materials in at
least the amounts consumed minus the city's own production?
2. If a city is built here, will the terrain provide all of the
materials needed to build any new units that the city might build? 
(Don't worry about how much is produced; just that it's produced at all)
3. Regarding question 2, what size must the city be in order to produce
all of those materials?  Will the terrain support a city of that size?**
4. If any of the above questions were answered with a "no", consider the
spot unsuitable for building and delete it from the list.

*  Perhaps if there is a hostile city overlapping the area, it should be
considered whether or not to attack.  But for now, I'll focus on
colonization, not combat.
** It might be worth considering the impact of facilities such as
granaries, but that entails more complexities than I'm willing to worry
about at this time.

--- END MECHANICAL THOUGHT PROCESS ---

I hope that this all makes sense.  The only problem I can see with this
setup might appear in games like "fantasy" or "postmodern", where cities
are non-advanced, but there are colonizer units that can build them. 
They would probably do best to just have their own algorithm that would
only consider the values in the productivity table.

So, does it make sense to anyone?  Any questions or comments?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]