]> git.scottworley.com Git - planeteer/commitdiff
Relative prices from the data file are percentages
authorScott Worley <sworley@chkno.net>
Wed, 2 Nov 2011 22:32:10 +0000 (15:32 -0700)
committerScott Worley <sworley@chkno.net>
Wed, 2 Nov 2011 22:32:10 +0000 (15:32 -0700)
Divide them by 100 before using them.

planeteer.go

index 4dbb27b28c3cb5ece9e5380d83a910f90fc163f0..53f69f1574c411b0d20b600b27459acfdacff1ee 100644 (file)
@@ -319,8 +319,8 @@ func FillCellBySelling(data planet_data, dims []int, table []State, addr []int)
                        continue
                }
                base_price := data.Commodities[commodity].BasePrice
-               absolute_price := relative_price * base_price
-               sell_price := int(float64(absolute_price) * 0.9)
+               absolute_price := float64(base_price) * float64(relative_price) / 100.0
+               sell_price := int(absolute_price * 0.9)
 
                for other[UnusedCargo] = 0; other[UnusedCargo] < dims[UnusedCargo]; other[UnusedCargo]++ {
 
@@ -350,7 +350,7 @@ func FillCellByBuying(data planet_data, dims []int, table []State, addr []int) {
                return
        }
        base_price := data.Commodities[commodity].BasePrice
-       absolute_price := relative_price * base_price
+       absolute_price := int(float64(base_price) * float64(relative_price) / 100.0)
        quantity := *hold - addr[UnusedCargo]
        total_price := quantity * absolute_price
        other[Hold] = 0