]> git.scottworley.com Git - planeteer/commitdiff
Follow the reverse energy gradient on Eden-selling worlds.
authorScott Worley <sworley@chkno.net>
Thu, 10 Nov 2011 05:24:39 +0000 (21:24 -0800)
committerScott Worley <sworley@chkno.net>
Thu, 10 Nov 2011 05:24:39 +0000 (21:24 -0800)
This fix is necessary to find the optimal strategy when Eden's
beacon is active.

planeteer.go

index e94ebe5bda36524a3a38775d68baa51cb8aec321..060456dae90b2fe30acd9383b4944bea3fc6272e 100644 (file)
@@ -483,7 +483,10 @@ addr []int, barrier chan<- bool) {
        FillStateTable2Iteration(data, dims, table, addr, FillCellBySelling)
        FillStateTable2Iteration(data, dims, table, addr, FillCellByBuying)
        FillStateTable2Iteration(data, dims, table, addr, FillCellByMisc)
-       barrier <- true
+       FillStateTable2Iteration(data, dims, table, addr, FillCellByBuyingEdens)
+       if barrier != nil {
+               barrier <- true
+       }
 }
 
 /* Filling the state table is a set of nested for loops NumDimensions deep.
@@ -509,6 +512,19 @@ func FillStateTable1(data planet_data, dims []int, table []State) {
        work_units := (float64(*fuel) + 1) * (float64(eden_capacity) + 1)
        work_done := 0.0
        for fuel_remaining := *fuel; fuel_remaining >= 0; fuel_remaining-- {
+               /* Make an Eden-buying pass (Eden vendors' energy gradient
+                * along the Edens dimension runs backwards) */
+               for edens_remaining := 0; edens_remaining <= eden_capacity; edens_remaining++ {
+                       for planet := range data.Planets {
+                               if _, available := data.Planets[planet].RelativePrices["Eden Warp Units"]; available {
+                                       addr := make([]int, len(dims))
+                                       addr[Edens] = edens_remaining
+                                       addr[Fuel] = fuel_remaining
+                                       addr[Location] = data.p2i[planet]
+                                       FillStateTable2(data, dims, table, addr, nil)
+                               }
+                       }
+               }
                for edens_remaining := eden_capacity; edens_remaining >= 0; edens_remaining-- {
                        /* Do the brunt of the work */
                        for planet := range data.Planets {
@@ -524,15 +540,6 @@ func FillStateTable1(data planet_data, dims []int, table []State) {
                        work_done++
                        print(fmt.Sprintf("\r%3.0f%%", 100*work_done/work_units))
                }
-               /* Make an Eden-buying pass (uphill) */
-               addr := make([]int, len(dims))
-               addr[Fuel] = fuel_remaining
-               for addr[Edens] = 0; addr[Edens] <= eden_capacity; addr[Edens]++ {
-                       for planet := range data.Planets {
-                               addr[Location] = data.p2i[planet]
-                               FillStateTable2Iteration(data, dims, table, addr, FillCellByBuyingEdens)
-                       }
-               }
        }
        print("\n")
 }