View unanswered posts | View active topics It is currently Wed Sep 08, 2010 10:31 pm



Reply to topic  [ 1 post ] 
Where is the code for chaning res amounts? 
Author Message
New
New

Joined: Mon Jul 06, 2009 6:28 am
Posts: 7
Post Where is the code for chaning res amounts?
I'm spending some time looking through the code for Resource Distribution in an attempt to figure out how resource amounts are stored and calculated and how they are shared between clients and the server.

As far as I could tell, older versions of Spacebuild had machine entities adding and subtracting resources on the think function, keeping a networked variable for the total amount of each resource in each network.

That method seems extraordinarily intensive, because every single variable was being updated each think step if there was a machine activated.

It occurred to me that a much less intensive intensive way to manage things is with a little application of mathematics. Because each machine adds or subtracts resources with a linear rate, a rate of change for each resource on a network can be calculated by summing the rates of each activated machine.

As long as both server and client have all the information on how each machine affects a certain resource, the only events that must be networked are the state of each machine. Then, using a time stamp and a starting total, both the client and server can accurately calculate the amount of a resource in a network using a simple linear rate equation, a=rt+i (where a is the actual amount, r is the rate, t is the time elapsed since the change, and i is the initial amount).

I'm not sure exactly how it is done now, but I am always interested by these sorts of things, and I would love to help devise the best way to make resource distribution work.


Tue Jul 07, 2009 3:19 am
Profile E-mail
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.