EnglishGermanFrenchRussianPolishItalianSpanish
Log inRegister
 
Preliminary info on Dock / Trade Station ware consumption rates
Post new topic Reply to topic
View previous topic :: View next topic
Author Message
Burianek





Joined: 29 Dec 2003
Posts: 2925 on topic
Location: Chicago, IL
Thank you for registering your game
PostPosted: Thu, 22. Dec 05, 22:55    Post subject: Preliminary info on Dock / Trade Station ware consumption rates Reply with quote Print

Hi all,

I've done a little bit of digging and managed to get some information on how the quantity of wares to be removed at equipment docks and trade stations is calculated.

This is preliminary information, and is subject to being completely incorrect, but I'll try to list what I know and what I'm guessing at so you can make up your own minds.

First, here's the code that deals with ware removal:
Code:

int use = current_timestep * percentage / (100 * (BESTSTORE/BESTSTORE_SECONDARY)) / SA_GetTypeRelValue(m, s);

if (use == 0)
{
  int invuse = SA_GetTypeRelValue(m, s) * (100 * (BESTSTORE/BESTSTORE_SECONDARY)) / (percentage * current_timestep);
  if (!invuse || !SE_Random(invuse)) {
    use = (current_timestep / 20) + 1;
  }
  else {
    use = 0;
  }
}


To those of you who don't know KC (I don't either) I'll explain what this means.

Let's take the first line:
Code:

int use = current_timestep * percentage / (100 * (BESTSTORE/BESTSTORE_SECONDARY)) / SA_GetTypeRelValue(m, s);


Some definitions:

current_timestep = this is a variable number, in seconds, of the length of time since the last iteration to check to see if wares should be removed. This number can be anywhere from 5 - 300 seconds if nothing interrupts the task.

percentage = 6 for 'high tech' wares (weapons / shields) and 12 for everything else

BESTSTORE = 10,000
BESTSTORE_SECONDARY = 5,000

SA_GetTypeRelValue(m, s) = returns the relvalue of the ware being checked, don't worry about the syntax. If you don't know what a relvalue is, you're probably not reading this tutorial anyway, since it's too advanced. Start out by reading my explanation of economy related matters in the X2 S/M forum.

Ok, so let's take wheat as an example, and let's assume that the current_timestep is 120 seconds. That gives us an equation of:
Code:

int use = 120 * 12 / (100 * (2)) / 6

this equals 1.2, but since it's an integer, it floors the value to 1

Now I don't know at this point how many wares get removed. I'm under the impression that use is more of a logical quantity and states whether or not wares should be removed. I don't think the code removes 'use' units since removing 1 wheat every 2 minutes would be silly. But this would require testing.

Also, let's note that wheat has a pretty small relvalue. Most wares are considerably higher. Wares that have relvalues higher than wheat are going to run into the dangerous possibility that use will end up being a number less than 1, and therefore the integer quantity will get floored to 0.

Let's move to the next part of the code, which deals with this possibility, and is the random function.
Code:

if (use == 0)
{
  int invuse = SA_GetTypeRelValue(m, s) * (100 * (BESTSTORE/BESTSTORE_SECONDARY)) / (percentage * current_timestep);
  if (!invuse || !SE_Random(invuse)) {
    use = (current_timestep / 20) + 1;
  }
  else {
    use = 0;
  }
}

Let me say this in english

If use ended up being 0, use this part of the code

invuse = blah blah... you'll see that this is simply the inverse of the equation used to find use. It is what it says it is, it's the inverse of use. So if use ended up being 0.25, invuse will be 4. (1 / 0.25 = 4)

if !invuse ..... - this line is the random function. it says, if invuse equals 4, there is a 1 / 4 (25%) chance of executing the next line. else go to the else part which sets use equal to zero.

The line that gets executed if the random function succeeds is:
use = (current_timestep / 20) + 1
This again sets use to some nonzero number. I'm not exactly sure why it isn't just set to 1, and what the timestep portion of the line does, but there you have it.

So really all that this entire second block of code says is:
'ok, use ended up being 0.30, then there's a 30% chance of having a nonzero use number'
'ok, use ended up being 0.58, then there's a 58% chance of having a nonzero use number'
you get the point.

Kind of clever actually since over large quantities of time, these random functions should balance out to produce something close to an average rate of consumption that can have considerable variation over the short term.

Now, I don't know what happens after use is determined. I don't know how many wares get removed. I don't think it's 1, but I don't know.

Many thanks to ticaki for helping me understand what little I've been able to present here.


_________________
"Nature's first green is gold" . . . stay golden.
Join the Guild Wars: X Universe Guild!
Back to top
View user's profile Send private message Visit poster's website
jlehtone
Moderator (Script&Mod)
Moderator (Script&Mod)

MEDALMEDALMEDAL

Joined: 23 Apr 2005
Posts: 16160 on topic
Location: GalNet BBS
Thank you for registering your game
PostPosted: Fri, 23. Dec 05, 10:52    Post subject: Re: Preliminary info on Dock / Trade Station ware consumption rates Reply with quote Print

Burianek wrote:
what little I've been able to present here.

Nuggets of gold, even when "little", are precious. Wink


_________________
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic Reply to topic
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Fri, 24. May 13, 16:38

All times are GMT + 2 Hours


Board Security

Copyright © EGOSOFT 1989-2009
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.19991 seconds, sql queries = 23