after looking at the python source code for dope wars, i realized there are no complex algorithms for trading drugs. but as i'm building drug wars, i'm looking for a way to limit the profit potential to a new player to keep it interesting (too much profit makes a game too easy to win).

it turns out that's easy to do even using simple math. an actual example using the drugs from that version of dope wars:

table of drugs + price range (minimum..maximum)

Acid 1000..4400

Cocaine 15000..29000

Hashish 480..1280

Heroin 5500..13000

Ludes 11..60

MDA 1500..4400

Opium 540..1250

PCP 1000..2500

Peyote 220..700

Shrooms 630..1300

Speed 90..250

Weed 315..890

from each of these drugs, we can see the minimum and maximum amount each will sell for. as an example, on a very good day i can buy lots of cocaine for $15,000, then i can turn around and sell it on another very good day for $29,000. that's a profit of $14,000 per unit of drug sold. nice!

we can calculate the differences between the max and minimum drug price:

Acid 3400

Cocaine 14000

Hashish 800

Heroin 7500

Ludes 49

MDA 2900

Opium 710

PCP 1500

Peyote 480

Shrooms 670

Speed 160

Weed 575

i think there are a few ways of looking at the profit margins. under a single trade it might be ((max-min)/(highest_max_of_all_drugs))*100. in dope wars, it's sometimes possible to assume you can purchase the max of any drug--so would you always want to purchase cocaine? the amount of return by the following (assuming no limit to buying a given drug):

((total money / min price) * max price) / total_money

to give a simple example, if you have $10,000 and you buy ludes, you can generate 5.4x return under the best scenario. this allows you to generate (max-min) a number of (total_money/min) times.

Acid 4.4x

Cocaine 1.9x

Hashish 2.5x

Heroin 2.3x

Ludes 5.4x <- the cheapest drug, also the most profitable

MDA 2.9x

Opium 2.3x

PCP 2.5x

Peyote 3.1x

Shrooms 2.0x

Speed 2.8x

Weed 2.8x

if you want to make a game like this difficult to beat, i think you'll want to:

- keep the difference between the max and min price low. this reduces the chance that a drug can be bought really low and sold really high.
- keep the minimum buying price high. this reduces the number of times the things from #1 can happen.

my instinct was that cocaine would be the best drug to purchase since it had the largest difference (one trade would at best earn you $14,000). but if there aren't any limits, you'd be better off doing a lot of smaller trades of ludes.

i haven't accounted for what you do in various situations when you have a limit on the drugs sold. this is in many versions of the game, so i'd need to understand the likelihood of how many drugs are available in an area first. i might write another post on that shortly, since that is really what we'd want to understand. you'd also want to consider how much money you have at any given time.

i think a strong algorithm would do a few things:

- cause all locations to have an initially low demand
- associate an addiction multiplier to each drug, so as the drug is purchased, the demand increases and so does the price
- increase the presence of a police force as a drug with a high addiction multiplier increases in a location, making the risk higher to trade
- create a cap on how many drugs can be traded in a location (e.g. sold between players or limited by the system)