+ 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]
+ }
+ }
+