Re: EXP Formula (Yes, again!)

From: George (greerga@CIRCLEMUD.ORG)
Date: 02/02/98


On Mon, 2 Feb 1998, ;P wrote:

>"exp = pow(2, level) * 1000" will give you something close to the above

Ugh, try 'exp = level * level * 1000;'  It'll eliminate a function call,
give the same results and not require the math library.

>int exp_to_level(struct char_data *ch)
>{
>  float exp;

If you cannot have partial experience (ie: 0.1), then why put a float that
will require much more processing? (At least under i386 platform with the
funny FPU.)  A 32-bit 'long' will give you 4.2 billion unsigned and if you
really need more, try a 64-bit 'long long' if you have it.

>  extern struct int_app_type int_app[];
>  extern struct wis_app_type wis_app[];
>  extern int exp_needed[];
>  extern float class_exp_mod[];

Out you evil daemons of nested externs!
(Try -Wnested-extern on CircleMUD and you'll see what I mean.)

>  exp = (float) exp_needed[(int) GET_LEVEL(ch)];
>  exp *= (float) class_exp_mod[(int) GET_CLASS(ch)];
>  exp *= (float) int_app[GET_INT(ch)].int_exp_mod;
>  exp *= (float) wis_app[GET_WIS(ch)].wis_exp_mod;
>
>  return ((int) exp);

That seems like a lot of funny business casting your integers as floats all
for nothing. Who cares how large your float is during processing if you
just change back to an integer anyway?  (You also get warnings on that
return line I believe, along the lines of lost precision.)

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST