From: Scott Worley Date: Fri, 4 Nov 2011 00:54:53 +0000 (-0700) Subject: Using an eden warp doesn't give you cargo. X-Git-Url: http://git.scottworley.com/planeteer/commitdiff_plain/d1ad6058bb610fc8880108ba7181f32642f69763?hp=d16f3322ace4634689f6b9c032da40b243b88ec8 Using an eden warp doesn't give you cargo. --- diff --git a/planeteer.go b/planeteer.go index 40d19dd..12bf879 100644 --- a/planeteer.go +++ b/planeteer.go @@ -221,7 +221,7 @@ func EncodeIndex(dims, addr []int) int { panic(0) } for i := 1; i < NumDimensions; i++ { - if addr[i] > dims[i] { + if addr[i] < 0 || addr[i] > dims[i] { panic(i) } index = index*dims[i] + addr[i] @@ -300,14 +300,16 @@ func FillCellByArriving(data planet_data, dims []int, table []State, addr []int) } /* Travel here via Eden Warp Unit */ - if addr[Edens]+1 < dims[Edens] { + if addr[Edens]+1 < dims[Edens] && addr[UnusedCargo] > 1 { _, available := data.Planets[data.i2p[addr[Location]]].RelativePrices["Eden Warp Units"] if !available { other[Edens] = addr[Edens] + 1 + other[UnusedCargo] = addr[UnusedCargo] - 1 for other[Location] = 0; other[Location] < dims[Location]; other[Location]++ { UpdateCell(table, my_index, EncodeIndex(dims, other), 0) } other[Location] = addr[Location] + other[UnusedCargo] = addr[UnusedCargo] other[Edens] = addr[Edens] } }