]> git.scottworley.com Git - planeteer/blobdiff - planeteer.go
Some safety against future modifications in DimensionSizes().
[planeteer] / planeteer.go
index 33f859ef346abf739d1eaa25b1e8d3bb66208987..314a3b62e62c18a4a8a7f259c33df374ffe6214b 100644 (file)
@@ -132,19 +132,22 @@ func bint(b bool) int {
 func DimensionSizes(data planet_data) []int {
        eden_capacity := data.Commodities["Eden Warp Units"].Limit
        cloak_capacity := bint(*cloak)
-       dims := []int{
-               eden_capacity + 1,
-               cloak_capacity + 1,
-               eden_capacity + cloak_capacity + 1,
-               *fuel + 1,
-               len(data.Planets),
-               len(data.Commodities),
-               bint(*drones > 0) + 1,
-               bint(*batteries > 0) + 1,
-               1 << uint(len(visit())),
-       }
-       if len(dims) != NumDimensions {
-               panic("Dimensionality mismatch")
+       dims := make([]int, NumDimensions)
+       dims[Edens] = eden_capacity + 1
+       dims[Cloaks] = cloak_capacity + 1
+       dims[UnusedCargo] = eden_capacity + cloak_capacity + 1
+       dims[Fuel] = *fuel + 1
+       dims[Location] = len(data.Planets)
+       dims[Hold] = len(data.Commodities)
+       dims[NeedFighters] = bint(*drones > 0) + 1
+       dims[NeedShields] = bint(*batteries > 0) + 1
+       dims[Visit] = 1 << uint(len(visit()))
+
+       // Remind myself to add a line above when adding new dimensions
+       for i, dim := range dims {
+               if dim < 1 {
+                       panic(i)
+               }
        }
        return dims
 }