+func InitializeStateTable(data planet_data, dims []int, table []State) {
+}
+
+/* Fill in the cell at address addr by looking at all the possible ways
+ * to reach this cell and selecting the best one.
+ *
+ * The other obvious implementation choice is to do this the other way
+ * around -- for each cell, conditionally overwrite all the other cells
+ * that are reachable *from* the considered cell. We choose gathering
+ * reads over scattering writes to avoid having to take a bunch of locks.
+ *
+ * The order that we check things here matters only for value ties. We
+ * keep the first best path. So when action order doesn't matter, the
+ * check that is performed first here will appear in the output first.
+ */
+func FillStateTableCell(data planet_data, dims []int, table []State, addr []int) {
+ my_index := EncodeIndex(dims, addr)
+ other := make([]int, NumDimensions)
+ copy(other, addr)
+
+ /* Travel here via a 2-fuel unit jump */
+ if addr[Fuel] + 2 < dims[Fuel] {
+ other[Fuel] = addr[Fuel] + 2
+ for p := 0; p < dims[Location]; p++ {
+ other[Location] = p
+ if table[EncodeIndex(dims, other)].value > table[my_index].value {
+ table[my_index].value = table[EncodeIndex(dims, other)].value
+ table[my_index].from = EncodeIndex(dims, other)
+ }
+ }
+ other[Location] = addr[Location]
+ other[Fuel] = addr[Fuel]
+ }
+
+ /* Travel here via a hidey hole */
+ if addr[Fuel] + 1 < dims[Fuel] {
+ hole_index := (dims[Fuel] - 1) - (addr[Fuel] + 1)
+ if hole_index < len(flight_plan()) {
+ other[Fuel] = addr[Fuel] + 1
+ other[Location] = data.p2i[flight_plan()[hole_index]]
+ if table[EncodeIndex(dims, other)].value > table[my_index].value {
+ table[my_index].value = table[EncodeIndex(dims, other)].value
+ table[my_index].from = EncodeIndex(dims, other)
+ }
+ other[Fuel] = addr[Fuel]
+ }
+ }
+
+ /* Travel here via Eden Warp Unit */
+ /* Silly: Dump Eden warp units */
+ /* Buy Eden warp units */
+ /* Buy a Device of Cloaking */
+ /* Silly: Dump a Device of Cloaking */
+ /* Buy Fighter Drones */
+ /* Buy Shield Batteries */
+ if addr[Hold] == 0 {
+ /* Sell or dump things */
+ // for commodity := range data.Commodities { }
+ } else {
+ /* Buy this thing */
+ }
+ /* Visit this planet */