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]

Re: More revisions to exploring_worth


On Mon, 2002-07-22 at 13:29, Hans Ronne wrote:
> Actually, a simple division by cps could work in this particular case,
> since other units do not appear in the formula. It's only when the hit
> tables get involved (as they do in the attack and defend formulas) that
> things get messed up. So I suggest that you try this next. Hopefully,
> destroyers will be more worth than battleships then.

And it seems that it does work.  I also added a fix that allows it to
correctly evaluate the consumption of units that consume materials while
moving, but also produce them (e.g. infantry and armor in the standard
game).

Now the code reads:

int
exploring_worth(int u)
{
    /* An important consideration in many games is if the range is a unit is
       limited by materials.  Try to determine the most limiting factor. */
    int velocity = u_acp(u) * u_speed(u) / 100;
    int range1 = 32767; /* By the end of the for_all_material_types loop, the range of the unit */
    int range2;         /* On each test, the candidate for the range (the smallest value is correct) */
    int mobility = 0;	/* Represents what portion of the map the unit can move around on */
    int worth, m, t, base;

    /* Assume that if um_consumption_per_move > 0, um_material_to_move > 0,
       and if either ( um_base_production - um_base_consumption ) < 0 or
       um_consumption_per_move > 0, then hp_per_starve > 0. */

    if ( velocity > 0 ) {
        for_all_material_types(m) {
            if ( um_storage_x(u, m) > 0 ) {
                /* This material can be stored; what is it used for? */
                base = um_base_production(u, m) - um_base_consumption(u, m);
                if ( base < 0 ) {
                    /* It is part of basic consumption. */
                    range2 = um_storage_x(u, m) / (-base);
                    /* Does it limit range any more than another material? */
                    if ( range2 < range1 )
                        range1 = range2;
                }

                if ( um_consumption_per_move(u, m) > 0 && um_consumption_per_move(u, m) * velocity > um_base_production(u, m) ) {
                    /* Some of it is consumed every time the unit moves. */
                    range2 = um_storage_x(u, m) / um_consumption_per_move(u, m) * velocity;
                    if ( range2 < range1 )
                        range1 = range2;
                }
            }
        }

        /* It should also be considered what kind of terrain the unit can move on, and how common that terrain is. */
        /* if ( g_synth_methods == what? */
            for_all_terrain_types(t) {
                if ( ( ! ut_vanishes_on(u, t) ) && ( ! ut_wrecks_on(u, t) ) ) {
                    /* Can explore this terrain without dying! */
                    mobility += ( ( t_alt_max(t) - t_alt_min(t) ) * ( t_wet_max(t) - t_wet_min(t) ) ) / ( ut_mp_to_enter(u, t) + 1 );
                }
            }
    }

    /* The most valuable explorers may be the fastest, or the longest-range, or the most mobile.
       Of course, range doesn't matter if materials aren't involved,
       and any attempt to consider materials for them would cause an overflow! */
    if ( range1 < 32767 )
        worth = velocity * range1 * mobility / u_cp(u);
    else
        worth = velocity * world.circumference * mobility / u_cp(u);

    DMprintf("unit type %s explorer worth %d \n ", u_type_name(u), worth);
    if (worth < 0)
	init_warning("%s has negative explorer worth", u_type_name(u));
    return worth;
}


And the explorer worths are now:

infantry:		135000
armor:			95657
fighter:		33750
bomber:			33750
destroyer:		103500
submarine:		64687
troop transport:	115000
carrier:		183093
battleship:		68660
nuclear bomb:		89100
base:			0
town:			0
city:			0

The numbers are a little large (and possibly a little hard to wrap one's
mind around), but I think that they look reasonable.


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