X-Git-Url: http://git.scottworley.com/planeteer/blobdiff_plain/42f6427c1fe90b4ae6f93e0e8a5737b0a3b566f1..ddef04ab661444f478e4602ba57784a4636f32ab:/planeteer.go diff --git a/planeteer.go b/planeteer.go index 5e406fa..a3a5a02 100644 --- a/planeteer.go +++ b/planeteer.go @@ -110,6 +110,7 @@ type Commodity struct { } type Planet struct { BeaconOn bool + Private bool /* Use relative prices rather than absolute prices because you can get relative prices without traveling to each planet. */ RelativePrices map[string]int @@ -336,6 +337,10 @@ func FillCellByArriving(data planet_data, dims []int, table []State, addr []int) } func FillCellBySelling(data planet_data, dims []int, table []State, addr []int) { + if data.Planets[data.i2p[addr[Location]]].Private { + // Can't do commerce on private planets + return + } if addr[Hold] > 0 { // Can't sell and still have cargo return @@ -373,6 +378,10 @@ func FillCellBySelling(data planet_data, dims []int, table []State, addr []int) } func FillCellByBuying(data planet_data, dims []int, table []State, addr []int) { + if data.Planets[data.i2p[addr[Location]]].Private { + // Can't do commerce on private planets + return + } if addr[Hold] == 0 { // Can't buy and then have nothing return @@ -575,15 +584,17 @@ func FindBestState(data planet_data, dims []int, table []State) int { addr[BuyFighters] = dims[BuyFighters] - 1 addr[BuyShields] = dims[BuyShields] - 1 addr[Visit] = dims[Visit] - 1 - // Fuel, Hold, UnusedCargo left at 0 + // Hold and UnusedCargo left at 0 max_index := -1 max_value := 0 - for addr[Location] = 0; addr[Location] < dims[Location]; addr[Location]++ { - if len(end()) == 0 || end()[data.i2p[addr[Location]]] { - index := EncodeIndex(dims, addr) - if table[index].value > max_value { - max_value = table[index].value - max_index = index + for addr[Fuel] = 0; addr[Fuel] < 2; addr[Fuel]++ { + for addr[Location] = 0; addr[Location] < dims[Location]; addr[Location]++ { + if len(end()) == 0 || end()[data.i2p[addr[Location]]] { + index := EncodeIndex(dims, addr) + if table[index].value > max_value { + max_value = table[index].value + max_index = index + } } } }