Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Aug 07, 2012 8:42 pm   

Compiling Multiple Variables
 
Okay, so I'm working on a cargo-running script for a SWR-type MUD. I have seen a few of these, but they seem either made for Zmud or just not well-done. Because nearly all planets have different resources, it has to take in the resources from each planet, then compile them all together. I will then have a predefined list of routes between planets (basing them off of close distance between each set of two planets). The compiled data will then need to be sorted to figure out what the highest and lowest matching resources are on each set of planets, then sorted for best routes. I'm thinking results can be figured by largest deficit. Here's a sample readout for the data for those that haven't done a cargo SWR.

Code:

You use the datapad to lookup the information.
--Planet Data: -------------------------------
Planet: Corellia
Starsystem: Corellian System
Governed By: The Galactic Empire
Planet Funds: 49643

Electronics          ( Price per unit: 1.32 )
Food                 ( Price per unit: 1.57 )
Goods                ( Price per unit: 11.98)
Medical supplies     ( Price per unit: 1.45 )
Precious metals      ( Price per unit: 0.46 )
Spice                ( Price per unit: 3.18 )
Tibanna gas          ( Price per unit: 1.00 )
Water                ( Price per unit: 2.32 )
Weapons              ( Price per unit: 0.73 )

Code:

You use the datapad to lookup the information.
--Planet Data: -------------------------------
Planet: Coruscant
Starsystem: Coruscant Sector
Governed By: The Galactic Empire
Planet Funds: 100000

Electronics          ( Price per unit: 1.19 )
Food                 ( Price per unit: 2.25 )
Goods                ( Price per unit: 1.00 )
Lumber               ( Price per unit: 9.01 )
Medical supplies     ( Price per unit: 4.45 )
Tibanna gas          ( Price per unit: 12.00)
Water                ( Price per unit: 6.84 )


As you can see, the best deal for this set is to buy tibanna gas on Corellia, sell it on Coruscant, then buy goods on Coruscant and sell them on Corellia. Tibanna gas deficit (11.00), Goods (10.98). Coruscant/Corellia deficit (21.98)

Code:

You use the datapad to lookup the information.
--Planet Data: -------------------------------
Planet: Ord Mantell
Starsystem: Bright Jewel System
Governed By: The Galactic Empire
Planet Funds: 25000

Electronics          ( Price per unit: 2.60 )
Food                 ( Price per unit: 0.88 )
Goods                ( Price per unit: 4.14 )
Lumber               ( Price per unit: 7.04 )
Medical supplies     ( Price per unit: 1.00 )
Precious metals      ( Price per unit: 8.96 )
Tibanna gas          ( Price per unit: 10.15)
Water                ( Price per unit: 1.00 )

Code:

You use the datapad to lookup the information.
--Planet Data: -------------------------------
Planet: Nal Hutta
Starsystem: Hutt Space
Governed By: The Galactic Empire
Planet Funds: 25000

Electronics          ( Price per unit: 2.38 )
Food                 ( Price per unit: 10.88)
Goods                ( Price per unit: 10.99)
Lumber               ( Price per unit: 10.15)
Medical supplies     ( Price per unit: 1.24 )
Spice                ( Price per unit: 1.40 )
Tibanna gas          ( Price per unit: 1.00 )


And the best deal for this set is to buy food on Ord Mantell, sell it on Nal Hutta, then buy Tibanna gas on Nal Hutta and sell it on Ord Mantell. Food deficit (10.00), Tibanna gas (9.15). Ord Mantell/Nal Hutta deficit (19.15)

Once this is done, it takes the total deficits from each route set, and displays it from most to least profitable, with a hyperlink to start a cargo-running script for that specific route. Something like:

Code:

Cargo Routes

1. Coruscant (Tibanna gas) - Corellia (Goods)
2. Ord Mantell (Tibanna gas) - Nal Hutta (Food)


Is this doable? I'm not quite sure how to set up the variables and do the math between them all.

Thanks!
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Wed Aug 08, 2012 6:42 pm   
 
Okay, I've got a trigger here that takes the resources and costs, and compiles it into a stringlist per planet, then sorts it into the proper order, so that all planet's $resource match.

Code:

$planet = @ResourcePlanet
$resource = %1
$amount = ((%3 * 100) + %4)
#ADDKEY @{ResourcePlanet}Resources {%concat($resource)=$amount}
sortplanetresources


Once that was done, I created a test alias to try to sort them out, displaying the most profitable to least profitable one-way between the two planets.

Code:

$deficit1 = @CoruscantResources.1-@CorelliaResources.1
$deficit2 = @CoruscantResources.2-@CorelliaResources.2
$deficit3 = @CoruscantResources.3-@CorelliaResources.3
$deficit4 = @CoruscantResources.4-@CorelliaResources.4
$deficit5 = @CoruscantResources.5-@CorelliaResources.5
$deficit6 = @CoruscantResources.6-@CorelliaResources.6
$deficit7 = @CoruscantResources.7-@CorelliaResources.7
$deficit8 = @CoruscantResources.8-@CorelliaResources.8
$deficit9 = @CoruscantResources.9-@CorelliaResources.9
$deficit10 = @CoruscantResources.10-@CorelliaResources.10
$deficit11 = @CoruscantResources.11-@CorelliaResources.11
$resource1 = Electronics
$resource2 = Food
$resource3 = Goods
$resource4 = Livestock
$resource5 = Lumber
$resource6 = Medical supplies
$resource7 = Precious metals
$resource8 = Spice
$resource9 = Tibanna gas
$resource10 = Water
$resource11 = Weapons
#ADDKEY CoruscantCorellia {$deficit1=$resource1|$deficit2=$resource2|$deficit3=$resource3|$deficit4=$resource4|$deficit5=$resource5|$deficit6=$resource6|$deficit7=$resource7|$deficit8=$resource8|$deficit9=$resource9|$deficit10=$resource10|$deficit11=$resource11}
#SHOWDB %sort(@CoruscantCorellia)


Obviously, it needs some work, but I'm trying to get the basic principle down for now. However, when I use the alias, it shows:

Code:

-306: Precious metals
-36: Spice
-393: Weapons
-50: Electronics
-910: Goods
0: Livestock
1100: Tibanna gas
135: Lumber
290: Medical supplies
445: Food
516: Water


Or, with them reversed with the "1" in the sort:

Code:

516: Water
445: Food
290: Medical supplies
135: Lumber
1100: Tibanna gas
0: Livestock
-910: Goods
-50: Electronics
-393: Weapons
-36: Spice
-306: Precious metals


Is there a different way I should put it? It should show the 1100: Tibanna gas at the top of the list.

Thanks!
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed Aug 08, 2012 7:22 pm   
 
As far as I can tell, you can only sort alphabetically with %sort, not numerically. If all you need is the highest deficit though, you could find that with %max. I don't have time to write out the code for it right now, but I'll see what I can do later.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net