func flight_plan() []string {
if flight_plan_cache == nil {
if *flight_plan_string == "" {
func flight_plan() []string {
if flight_plan_cache == nil {
if *flight_plan_string == "" {
/* Use relative prices rather than absolute prices because you
can get relative prices without traveling to each planet. */
RelativePrices map[string]int
/* Use relative prices rather than absolute prices because you
can get relative prices without traveling to each planet. */
RelativePrices map[string]int
- Edens = iota // 1 3 # of Eden warp units (0 - 2 typically)
- Cloaks // 2 1-2 # of Devices of Cloaking (0 or 1)
- UnusedCargo // 3 4 # of unused cargo spaces (0 - 3 typically)
- Fuel // 4 17 Hyper jump power left (0 - 16)
- Location // 5 26 Location (which planet)
- Hold // 6 15 Cargo bay contents (a *Commodity or nil)
- Traded // 7 2 Traded yet?
- BuyFighters // 8 1-2 Errand: Buy fighter drones
- BuyShields // 9 1-2 Errand: Buy shield batteries
- Visit // 10 1-2**N Visit: Stop by these N planets in the route
+ Edens = iota // 1 3 # of Eden warp units (0 - 2 typically)
+ Cloaks // 2 1-2 # of Devices of Cloaking (0 or 1)
+ UnusedCargo // 3 4 # of unused cargo spaces (0 - 3 typically)
+ Fuel // 4 17 Hyper jump power left (0 - 16)
+ Location // 5 26 Location (which planet)
+ Hold // 6 15 Cargo bay contents (a *Commodity or nil)
+ Traded // 7 2 Traded yet?
+ BuyFighters // 8 1-2 Errand: Buy fighter drones
+ BuyShields // 9 1-2 Errand: Buy shield batteries
+ Visit // 10 1-2**N Visit: Stop by these N planets in the route
func CreateStateTable(data planet_data, dims []int) []State {
table := make([]State, StateTableSize(dims))
for i := range table {
func CreateStateTable(data planet_data, dims []int) []State {
table := make([]State, StateTableSize(dims))
for i := range table {
- table[EncodeIndex(dims, addr)].value = int32(*funds)
+ start_index := EncodeIndex(dims, addr)
+ table[start_index].value = int32(*funds)
+ table[start_index].from = FROM_ROOT
func CellValue(data planet_data, dims []int, table []State, addr []int) int32 {
my_index := EncodeIndex(dims, addr)
func CellValue(data planet_data, dims []int, table []State, addr []int) int32 {
my_index := EncodeIndex(dims, addr)
best_source := make([]int, NumDimensions)
other := make([]int, NumDimensions)
copy(other, addr)
best_source := make([]int, NumDimensions)
other := make([]int, NumDimensions)
copy(other, addr)
- Consider(data, dims, table, other, -absolute_price * *drones, &best_value, best_source)
+ Consider(data, dims, table, other, -absolute_price**drones, &best_value, best_source)
- Consider(data, dims, table, other, -absolute_price * *batteries, &best_value, best_source)
+ Consider(data, dims, table, other, -absolute_price**batteries, &best_value, best_source)
other[Visit] = addr[Visit] & ^(1 << i)
Consider(data, dims, table, other, 0, &best_value, best_source)
}
other[Visit] = addr[Visit] & ^(1 << i)
Consider(data, dims, table, other, 0, &best_value, best_source)
}
- Consider(data, dims, table, other, -absolute_price * quantity, &best_value, best_source)
+ Consider(data, dims, table, other, -absolute_price*quantity, &best_value, best_source)
// Sanity check: This cell was in state BEING_EVALUATED
// the whole time that it was being evaluated.
// Sanity check: This cell was in state BEING_EVALUATED
// the whole time that it was being evaluated.
}
func DescribePath(data planet_data, dims []int, table []State, start int32) (description []string) {
}
func DescribePath(data planet_data, dims []int, table []State, start int32) (description []string) {
var line string
addr := DecodeIndex(dims, index)
prev := DecodeIndex(dims, table[index].from)
var line string
addr := DecodeIndex(dims, index)
prev := DecodeIndex(dims, table[index].from)
to := data.i2p[addr[Location]]
line += fmt.Sprintf("Jump from %v to %v (%v hyper jump units)", from, to, prev[Fuel]-addr[Fuel])
}
to := data.i2p[addr[Location]]
line += fmt.Sprintf("Jump from %v to %v (%v hyper jump units)", from, to, prev[Fuel]-addr[Fuel])
}
from := data.i2p[prev[Location]]
to := data.i2p[addr[Location]]
line += fmt.Sprintf("Eden warp from %v to %v", from, to)
from := data.i2p[prev[Location]]
to := data.i2p[addr[Location]]
line += fmt.Sprintf("Eden warp from %v to %v", from, to)
}
if addr[BuyShields] == 1 && prev[BuyShields] == 0 {
line += fmt.Sprint("Buy ", *batteries, " Shield Batterys")
}
if addr[BuyShields] == 1 && prev[BuyShields] == 0 {
line += fmt.Sprint("Buy ", *batteries, " Shield Batterys")