Jump to content

kOS bug


MAFman

Recommended Posts

I found a potential bug in kOS, where I try to create a maneuver node from a list of four values, and it returns the error "Cannot iterate on an object of type kOS.Safe.Encapsulation.ScalarIntValue. What's going on?

Link to comment
Share on other sites

It's impossible to tell from that information.  Can you post the log to see the rest of the error dump, and what the kerboscript code was doing?  The full dump won't just show the error message, but will show where in the code it happened.

 

Edited by Steven Mading
Link to comment
Share on other sites

11 minutes ago, Steven Mading said:

It's impossible to tell from that information.  Can you post the log to see the rest of the error dump, and what the kerboscript code was doing?  The full dump won't just show the error message, but will show where in the code it happened.

 

Where would I find this log?

Link to comment
Share on other sites

Found it!

[LOG 17:41:24.448] kOS: At 0:/libraries/interplanetary.ks, line 23
    local t is data[0].
                    ^
Called from 0:/libraries/interplanetary.ks, line 55
      local maneuver is makeNode(data).
                                 ^
Called from 0:/libraries/hillclimb.ks, line 17
    until fitness_fn(next_data) <= fitness_fn(data) {
                     ^
Called from 0:/libraries/interplanetary.ks, line 11
    set data to hillclimb["seek"](data, transferFit(targetBody), 1).
                                                                 ^
Called from 0:/startup/mariner 4.ks, line 13
    add interplanetary["seek"](Duna, 1000000).
                                     ^
Called from 1:/boot/boot.ks, line 8
if exists(startupFile) runpath(startupFile).
                               ^
Called from [Boot sequence], line 1
run "/boot/boot.ks".
    ^

[LOG 17:41:24.448] System.Exception: Can't iterate on an object of type kOS.Safe.Encapsulation.ScalarIntValue
  at kOS.Safe.Compilation.OpcodeGetIndex.Execute (kOS.Safe.Execution.ICpu cpu) [0x00034] in <1f05d5b75d1c42729d0e0281470dcabd>:0 
  at kOS.Safe.Execution.CPU.ExecuteInstruction (kOS.Safe.Execution.ProgramContext context, System.Boolean doProfiling) [0x001e5] in <1f05d5b75d1c42729d0e0281470dcabd>:0 
  at kOS.Safe.Execution.CPU.ContinueExecution (System.Boolean doProfiling) [0x00030] in <1f05d5b75d1c42729d0e0281470dcabd>:0 
  at kOS.Safe.Execution.CPU.KOSFixedUpdate (System.Double deltaTime) [0x000b0] in <1f05d5b75d1c42729d0e0281470dcabd>:0 
[LOG 17:41:24.448] Code Fragment
File                 Line:Col IP   label   opcode operand
====                 ====:=== ==== ================================  
0:/libraries/interplanetary.ks   18:38  2079 @2041   push $attempt 
0:/libraries/interplanetary.ks   18:36  2080 @2042   mult 
0:/libraries/interplanetary.ks   18:30  2081 @2043   add 
0:/libraries/interplanetary.ks   18:48  2082 @2044   push 0 
0:/libraries/interplanetary.ks   18:51  2083 @2045   push 0 
0:/libraries/interplanetary.ks   18:54  2084 @2046   push 0 
0:/libraries/interplanetary.ks   18:54  2085 @2047   call list() 
0:/libraries/interplanetary.ks   18:54  2086 @2048   return 1 deep 
0:/libraries/interplanetary.ks   19:3   2087 @2049   popscope 1 
0:/libraries/interplanetary.ks   19:3   2088 @2050   push 0 
0:/libraries/interplanetary.ks   19:3   2089 @2051   return 0 deep 
0:/libraries/interplanetary.ks   21:21  2090 makenode`88-cf6e194b pushscope 91 88 
0:/libraries/interplanetary.ks   22:5   2091 @2053   storelocal $data 
0:/libraries/interplanetary.ks   22:5   2092 @2054   argbottom 
0:/libraries/interplanetary.ks   23:16  2093 @2055   push $data 
0:/libraries/interplanetary.ks   23:21  2094 @2056   push 0 
0:/libraries/interplanetary.ks   23:21  2095 @2057   getindex <<--INSTRUCTION POINTER--
0:/libraries/interplanetary.ks   23:21  2096 @2058   storelocal $t 
0:/libraries/interplanetary.ks   24:18  2097 @2059   push $data 
0:/libraries/interplanetary.ks   24:23  2098 @2060   push 1 
0:/libraries/interplanetary.ks   24:23  2099 @2061   getindex 
0:/libraries/interplanetary.ks   24:23  2100 @2062   storelocal $rad 
0:/libraries/interplanetary.ks   25:18  2101 @2063   push $data 
0:/libraries/interplanetary.ks   25:23  2102 @2064   push 2 
0:/libraries/interplanetary.ks   25:23  2103 @2065   getindex 
0:/libraries/interplanetary.ks   25:23  2104 @2066   storelocal $nrm 
0:/libraries/interplanetary.ks   26:19  2105 @2067   push $data 
0:/libraries/interplanetary.ks   26:24  2106 @2068   push 3 
0:/libraries/interplanetary.ks   26:24  2107 @2069   getindex 
0:/libraries/interplanetary.ks   26:24  2108 @2070   storelocal $prog 
0:/libraries/interplanetary.ks   27:16  2109 @2071   push _KOSArgMarker_ 
0:/libraries/interplanetary.ks   27:17  2110 @2072   push $t 
0:/libraries/interplanetary.ks   27:20  2111 @2073   push $rad 

[LOG 17:41:24.450] kOS: Argument Stack dump:
Argument Stack: count = 9
008 SP-> _KOSArgMarker_ (type: KOSArgMarkerType)

007      _KOSArgMarker_ (type: KOSArgMarkerType)

006      _KOSArgMarker_ (type: KOSArgMarkerType)

005      _KOSArgMarker_ (type: KOSArgMarkerType)

004      _KOSArgMarker_ (type: KOSArgMarkerType)

003      _KOSArgMarker_ (type: KOSArgMarkerType)

002      _KOSArgMarker_ (type: KOSArgMarkerType)

001      _KOSArgMarker_ (type: KOSArgMarkerType)

000      _KOSArgMarker_ (type: KOSArgMarkerType)

Scope Stack: count = 31
030 SP-> kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=91, ParentScopeId=88, IsClosure=False
            local var $data is Variable with value = $data
029      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=88, ParentScopeId=87, IsClosure=True
            local var $seek* is Variable with value = $seek*
            local var $startingdata* is Variable with value = $startingdata*
            local var $makenode* is Variable with value = $makenode*
            local var $removenodes* is Variable with value = $removenodes*
            local var $escapefit* is Variable with value = $escapefit*
            local var $transferfit* is Variable with value = $transferfit*
            local var $pefit* is Variable with value = $pefit*
            local var $closest_approach* is Variable with value = $closest_approach*
            local var $slope_at* is Variable with value = $slope_at*
            local var $separation_at* is Variable with value = $separation_at*
            local var $transfers_to* is Variable with value = $transfers_to*
            local var $infinity is Variable with value = $infinity
028      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=87, ParentScopeId=0, IsClosure=True
027      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=0, ParentScopeId=-1, IsClosure=True
            local var $SAS is BoundVariable with value = SAS
            local var $GEAR is BoundVariable with value = GEAR
            local var $LEGS is BoundVariable with value = LEGS
            local var $CHUTES is BoundVariable with value = CHUTES
            local var $CHUTESSAFE is BoundVariable with value = CHUTESSAFE
            local var $LIGHTS is BoundVariable with value = LIGHTS
            local var $PANELS is BoundVariable with value = PANELS
            local var $RADIATORS is BoundVariable with value = RADIATORS
            local var $LADDERS is BoundVariable with value = LADDERS
            local var $BAYS is BoundVariable with value = BAYS
            local var $DEPLOYDRILLS is BoundVariable with value = DEPLOYDRILLS
            local var $DRILLS is BoundVariable with value = DRILLS
            local var $FUELCELLS is BoundVariable with value = FUELCELLS
            local var $ISRU is BoundVariable with value = ISRU
            local var $INTAKES is BoundVariable with value = INTAKES
            local var $BRAKES is BoundVariable with value = BRAKES
            local var $RCS is BoundVariable with value = RCS
            local var $ABORT is BoundVariable with value = ABORT
            local var $AG1 is BoundVariable with value = AG1
            local var $AG2 is BoundVariable with value = AG2
            local var $AG3 is BoundVariable with value = AG3
            local var $AG4 is BoundVariable with value = AG4
            local var $AG5 is BoundVariable with value = AG5
            local var $AG6 is BoundVariable with value = AG6
            local var $AG7 is BoundVariable with value = AG7
            local var $AG8 is BoundVariable with value = AG8
            local var $AG9 is BoundVariable with value = AG9
            local var $AG10 is BoundVariable with value = AG10
            local var $CONFIG is BoundVariable with value = CONFIG
            local var $ADDONS is BoundVariable with value = ADDONS
            local var $WHITE is BoundVariable with value = WHITE
            local var $BLACK is BoundVariable with value = BLACK
            local var $RED is BoundVariable with value = RED
            local var $GREEN is BoundVariable with value = GREEN
            local var $BLUE is BoundVariable with value = BLUE
            local var $YELLOW is BoundVariable with value = YELLOW
            local var $MAGENTA is BoundVariable with value = MAGENTA
            local var $PURPLE is BoundVariable with value = PURPLE
            local var $CYAN is BoundVariable with value = CYAN
            local var $GREY is BoundVariable with value = GREY
            local var $GRAY is BoundVariable with value = GRAY
            local var $DONOTHING is BoundVariable with value = DONOTHING
            local var $THROTTLE is BoundVariable with value = THROTTLE
            local var $STEERING is BoundVariable with value = STEERING
            local var $WHEELSTEERING is BoundVariable with value = WHEELSTEERING
            local var $WHEELTHROTTLE is BoundVariable with value = WHEELTHROTTLE
            local var $SASMODE is BoundVariable with value = SASMODE
            local var $NAVMODE is BoundVariable with value = NAVMODE
            local var $ALT is BoundVariable with value = ALT
            local var $ANGULARVELOCITY is BoundVariable with value = ANGULARVELOCITY
            local var $ENCOUNTER is BoundVariable with value = ENCOUNTER
            local var $ETA is BoundVariable with value = ETA
            local var $MISSIONTIME is BoundVariable with value = MISSIONTIME
            local var $OBT is BoundVariable with value = OBT
            local var $ORBIT is BoundVariable with value = ORBIT
            local var $TIME is BoundVariable with value = TIME
            local var $ACTIVESHIP is BoundVariable with value = ACTIVESHIP
            local var $STATUS is BoundVariable with value = STATUS
            local var $STAGE is BoundVariable with value = STAGE
            local var $SHIPNAME is BoundVariable with value = SHIPNAME
            local var $STEERINGMANAGER is BoundVariable with value = STEERINGMANAGER
            local var $NEXTNODE is BoundVariable with value = NEXTNODE
            local var $HASNODE is BoundVariable with value = HASNODE
            local var $ALLNODES is BoundVariable with value = ALLNODES
            local var $CORE is BoundVariable with value = CORE
            local var $SHIP is BoundVariable with value = SHIP
            local var $HEADING is BoundVariable with value = HEADING
            local var $PROGRADE is BoundVariable with value = PROGRADE
            local var $RETROGRADE is BoundVariable with value = RETROGRADE
            local var $FACING is BoundVariable with value = FACING
            local var $MAXTHRUST is BoundVariable with value = MAXTHRUST
            local var $AVAILABLETHRUST is BoundVariable with value = AVAILABLETHRUST
            local var $VELOCITY is BoundVariable with value = VELOCITY
            local var $GEOPOSITION is BoundVariable with value = GEOPOSITION
            local var $LATITUDE is BoundVariable with value = LATITUDE
            local var $LONGITUDE is BoundVariable with value = LONGITUDE
            local var $UP is BoundVariable with value = UP
            local var $NORTH is BoundVariable with value = NORTH
            local var $BODY is BoundVariable with value = BODY
            local var $ANGULARMOMENTUM is BoundVariable with value = ANGULARMOMENTUM
            local var $ANGULARVEL is BoundVariable with value = ANGULARVEL
            local var $MASS is BoundVariable with value = MASS
            local var $VERTICALSPEED is BoundVariable with value = VERTICALSPEED
            local var $SURFACESPEED is BoundVariable with value = SURFACESPEED
            local var $GROUNDSPEED is BoundVariable with value = GROUNDSPEED
            local var $AIRSPEED is BoundVariable with value = AIRSPEED
            local var $ALTITUDE is BoundVariable with value = ALTITUDE
            local var $APOAPSIS is BoundVariable with value = APOAPSIS
            local var $PERIAPSIS is BoundVariable with value = PERIAPSIS
            local var $SENSOR is BoundVariable with value = SENSOR
            local var $SRFPROGRADE is BoundVariable with value = SRFPROGRADE
            local var $SRFRETROGRADE is BoundVariable with value = SRFRETROGRADE
            local var $TARGET is BoundVariable with value = TARGET
            local var $HASTARGET is BoundVariable with value = HASTARGET
            local var $SESSIONTIME is BoundVariable with value = SESSIONTIME
            local var $VOLUME:NAME is BoundVariable with value = VOLUME:NAME
            local var $TERMINAL is BoundVariable with value = TERMINAL
            local var $KUNIVERSE is BoundVariable with value = KUNIVERSE
            local var $HOMECONNECTION is BoundVariable with value = HOMECONNECTION
            local var $CONTROLCONNECTION is BoundVariable with value = CONTROLCONNECTION
            local var $WARPMODE is BoundVariable with value = WARPMODE
            local var $WARP is BoundVariable with value = WARP
            local var $MAPVIEW is BoundVariable with value = MAPVIEW
            local var $CONSTANT is BoundVariable with value = CONSTANT
            local var $VERSION is BoundVariable with value = VERSION
            local var $SOLARPRIMEVECTOR is BoundVariable with value = SOLARPRIMEVECTOR
            local var $ARCHIVE is BoundVariable with value = ARCHIVE
            local var $Sun is BoundVariable with value = Sun
            local var $Kerbin is BoundVariable with value = Kerbin
            local var $Mun is BoundVariable with value = Mun
            local var $Minmus is BoundVariable with value = Minmus
            local var $Moho is BoundVariable with value = Moho
            local var $Eve is BoundVariable with value = Eve
            local var $Duna is BoundVariable with value = Duna
            local var $Ike is BoundVariable with value = Ike
            local var $Jool is BoundVariable with value = Jool
            local var $Laythe is BoundVariable with value = Laythe
            local var $Vall is BoundVariable with value = Vall
            local var $Bop is BoundVariable with value = Bop
            local var $Tylo is BoundVariable with value = Tylo
            local var $Gilly is BoundVariable with value = Gilly
            local var $Pol is BoundVariable with value = Pol
            local var $Dres is BoundVariable with value = Dres
            local var $Eeloo is BoundVariable with value = Eeloo
            local var $message* is Variable with value = $message*
            local var $startupfile is Variable with value = $startupfile
            local var $steering* is Variable with value = $steering*
            local var $throttle* is Variable with value = $throttle*
            local var $ascent* is Variable with value = $ascent*
            local var $insertion* is Variable with value = $insertion*
            local var $azimuth* is Variable with value = $azimuth*
            local var $ascent is Variable with value = $ascent
            local var $maneuver is Variable with value = $maneuver
            local var $hillclimb is Variable with value = $hillclimb
            local var $transfer is Variable with value = $transfer
            local var $interplanetary is Variable with value = $interplanetary
            local var $gtconstant is Variable with value = $gtconstant
            local var $myens is Variable with value = $myens
            local var $solid is Variable with value = $solid
            local var $apvel is Variable with value = $apvel
            local var $r is Variable with value = $r
            local var $sma is Variable with value = $sma
            local var $targetvel is Variable with value = $targetvel
            local var $ens is Variable with value = $ens
            local var $ensthr is Variable with value = $ensthr
            local var $ensisp is Variable with value = $ensisp
            local var $myengines is Variable with value = $myengines
            local var $data is Variable with value = $data
026      SubroutineContext: {CameFromInstPtr 2186, TriggerPointer } (type: SubroutineContext)

025      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=98, ParentScopeId=97, IsClosure=False
            local var $data is Variable with value = $data
024      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=97, ParentScopeId=88, IsClosure=True
            local var $fitness_fn* is Variable with value = $fitness_fn*
            local var $targetbody is Variable with value = $targetbody
023      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=88, ParentScopeId=87, IsClosure=True
            local var $seek* is Variable with value = $seek*
            local var $startingdata* is Variable with value = $startingdata*
            local var $makenode* is Variable with value = $makenode*
            local var $removenodes* is Variable with value = $removenodes*
            local var $escapefit* is Variable with value = $escapefit*
            local var $transferfit* is Variable with value = $transferfit*
            local var $pefit* is Variable with value = $pefit*
            local var $closest_approach* is Variable with value = $closest_approach*
            local var $slope_at* is Variable with value = $slope_at*
            local var $separation_at* is Variable with value = $separation_at*
            local var $transfers_to* is Variable with value = $transfers_to*
            local var $infinity is Variable with value = $infinity
022      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=87, ParentScopeId=0, IsClosure=True
021      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=0, ParentScopeId=-1, IsClosure=True
            local var $SAS is BoundVariable with value = SAS
            local var $GEAR is BoundVariable with value = GEAR
            local var $LEGS is BoundVariable with value = LEGS
            local var $CHUTES is BoundVariable with value = CHUTES
            local var $CHUTESSAFE is BoundVariable with value = CHUTESSAFE
            local var $LIGHTS is BoundVariable with value = LIGHTS
            local var $PANELS is BoundVariable with value = PANELS
            local var $RADIATORS is BoundVariable with value = RADIATORS
            local var $LADDERS is BoundVariable with value = LADDERS
            local var $BAYS is BoundVariable with value = BAYS
            local var $DEPLOYDRILLS is BoundVariable with value = DEPLOYDRILLS
            local var $DRILLS is BoundVariable with value = DRILLS
            local var $FUELCELLS is BoundVariable with value = FUELCELLS
            local var $ISRU is BoundVariable with value = ISRU
            local var $INTAKES is BoundVariable with value = INTAKES
            local var $BRAKES is BoundVariable with value = BRAKES
            local var $RCS is BoundVariable with value = RCS
            local var $ABORT is BoundVariable with value = ABORT
            local var $AG1 is BoundVariable with value = AG1
            local var $AG2 is BoundVariable with value = AG2
            local var $AG3 is BoundVariable with value = AG3
            local var $AG4 is BoundVariable with value = AG4
            local var $AG5 is BoundVariable with value = AG5
            local var $AG6 is BoundVariable with value = AG6
            local var $AG7 is BoundVariable with value = AG7
            local var $AG8 is BoundVariable with value = AG8
            local var $AG9 is BoundVariable with value = AG9
            local var $AG10 is BoundVariable with value = AG10
            local var $CONFIG is BoundVariable with value = CONFIG
            local var $ADDONS is BoundVariable with value = ADDONS
            local var $WHITE is BoundVariable with value = WHITE
            local var $BLACK is BoundVariable with value = BLACK
            local var $RED is BoundVariable with value = RED
            local var $GREEN is BoundVariable with value = GREEN
            local var $BLUE is BoundVariable with value = BLUE
            local var $YELLOW is BoundVariable with value = YELLOW
            local var $MAGENTA is BoundVariable with value = MAGENTA
            local var $PURPLE is BoundVariable with value = PURPLE
            local var $CYAN is BoundVariable with value = CYAN
            local var $GREY is BoundVariable with value = GREY
            local var $GRAY is BoundVariable with value = GRAY
            local var $DONOTHING is BoundVariable with value = DONOTHING
            local var $THROTTLE is BoundVariable with value = THROTTLE
            local var $STEERING is BoundVariable with value = STEERING
            local var $WHEELSTEERING is BoundVariable with value = WHEELSTEERING
            local var $WHEELTHROTTLE is BoundVariable with value = WHEELTHROTTLE
            local var $SASMODE is BoundVariable with value = SASMODE
            local var $NAVMODE is BoundVariable with value = NAVMODE
            local var $ALT is BoundVariable with value = ALT
            local var $ANGULARVELOCITY is BoundVariable with value = ANGULARVELOCITY
            local var $ENCOUNTER is BoundVariable with value = ENCOUNTER
            local var $ETA is BoundVariable with value = ETA
            local var $MISSIONTIME is BoundVariable with value = MISSIONTIME
            local var $OBT is BoundVariable with value = OBT
            local var $ORBIT is BoundVariable with value = ORBIT
            local var $TIME is BoundVariable with value = TIME
            local var $ACTIVESHIP is BoundVariable with value = ACTIVESHIP
            local var $STATUS is BoundVariable with value = STATUS
            local var $STAGE is BoundVariable with value = STAGE
            local var $SHIPNAME is BoundVariable with value = SHIPNAME
            local var $STEERINGMANAGER is BoundVariable with value = STEERINGMANAGER
            local var $NEXTNODE is BoundVariable with value = NEXTNODE
            local var $HASNODE is BoundVariable with value = HASNODE
            local var $ALLNODES is BoundVariable with value = ALLNODES
            local var $CORE is BoundVariable with value = CORE
            local var $SHIP is BoundVariable with value = SHIP
            local var $HEADING is BoundVariable with value = HEADING
            local var $PROGRADE is BoundVariable with value = PROGRADE
            local var $RETROGRADE is BoundVariable with value = RETROGRADE
            local var $FACING is BoundVariable with value = FACING
            local var $MAXTHRUST is BoundVariable with value = MAXTHRUST
            local var $AVAILABLETHRUST is BoundVariable with value = AVAILABLETHRUST
            local var $VELOCITY is BoundVariable with value = VELOCITY
            local var $GEOPOSITION is BoundVariable with value = GEOPOSITION
            local var $LATITUDE is BoundVariable with value = LATITUDE
            local var $LONGITUDE is BoundVariable with value = LONGITUDE
            local var $UP is BoundVariable with value = UP
            local var $NORTH is BoundVariable with value = NORTH
            local var $BODY is BoundVariable with value = BODY
            local var $ANGULARMOMENTUM is BoundVariable with value = ANGULARMOMENTUM
            local var $ANGULARVEL is BoundVariable with value = ANGULARVEL
            local var $MASS is BoundVariable with value = MASS
            local var $VERTICALSPEED is BoundVariable with value = VERTICALSPEED
            local var $SURFACESPEED is BoundVariable with value = SURFACESPEED
            local var $GROUNDSPEED is BoundVariable with value = GROUNDSPEED
            local var $AIRSPEED is BoundVariable with value = AIRSPEED
            local var $ALTITUDE is BoundVariable with value = ALTITUDE
            local var $APOAPSIS is BoundVariable with value = APOAPSIS
            local var $PERIAPSIS is BoundVariable with value = PERIAPSIS
            local var $SENSOR is BoundVariable with value = SENSOR
            local var $SRFPROGRADE is BoundVariable with value = SRFPROGRADE
            local var $SRFRETROGRADE is BoundVariable with value = SRFRETROGRADE
            local var $TARGET is BoundVariable with value = TARGET
            local var $HASTARGET is BoundVariable with value = HASTARGET
            local var $SESSIONTIME is BoundVariable with value = SESSIONTIME
            local var $VOLUME:NAME is BoundVariable with value = VOLUME:NAME
            local var $TERMINAL is BoundVariable with value = TERMINAL
            local var $KUNIVERSE is BoundVariable with value = KUNIVERSE
            local var $HOMECONNECTION is BoundVariable with value = HOMECONNECTION
            local var $CONTROLCONNECTION is BoundVariable with value = CONTROLCONNECTION
            local var $WARPMODE is BoundVariable with value = WARPMODE
            local var $WARP is BoundVariable with value = WARP
            local var $MAPVIEW is BoundVariable with value = MAPVIEW
            local var $CONSTANT is BoundVariable with value = CONSTANT
            local var $VERSION is BoundVariable with value = VERSION
            local var $SOLARPRIMEVECTOR is BoundVariable with value = SOLARPRIMEVECTOR
            local var $ARCHIVE is BoundVariable with value = ARCHIVE
            local var $Sun is BoundVariable with value = Sun
            local var $Kerbin is BoundVariable with value = Kerbin
            local var $Mun is BoundVariable with value = Mun
            local var $Minmus is BoundVariable with value = Minmus
            local var $Moho is BoundVariable with value = Moho
            local var $Eve is BoundVariable with value = Eve
            local var $Duna is BoundVariable with value = Duna
            local var $Ike is BoundVariable with value = Ike
            local var $Jool is BoundVariable with value = Jool
            local var $Laythe is BoundVariable with value = Laythe
            local var $Vall is BoundVariable with value = Vall
            local var $Bop is BoundVariable with value = Bop
            local var $Tylo is BoundVariable with value = Tylo
            local var $Gilly is BoundVariable with value = Gilly
            local var $Pol is BoundVariable with value = Pol
            local var $Dres is BoundVariable with value = Dres
            local var $Eeloo is BoundVariable with value = Eeloo
            local var $message* is Variable with value = $message*
            local var $startupfile is Variable with value = $startupfile
            local var $steering* is Variable with value = $steering*
            local var $throttle* is Variable with value = $throttle*
            local var $ascent* is Variable with value = $ascent*
            local var $insertion* is Variable with value = $insertion*
            local var $azimuth* is Variable with value = $azimuth*
            local var $ascent is Variable with value = $ascent
            local var $maneuver is Variable with value = $maneuver
            local var $hillclimb is Variable with value = $hillclimb
            local var $transfer is Variable with value = $transfer
            local var $interplanetary is Variable with value = $interplanetary
            local var $gtconstant is Variable with value = $gtconstant
            local var $myens is Variable with value = $myens
            local var $solid is Variable with value = $solid
            local var $apvel is Variable with value = $apvel
            local var $r is Variable with value = $r
            local var $sma is Variable with value = $sma
            local var $targetvel is Variable with value = $targetvel
            local var $ens is Variable with value = $ens
            local var $ensthr is Variable with value = $ensthr
            local var $ensisp is Variable with value = $ensisp
            local var $myengines is Variable with value = $myengines
            local var $data is Variable with value = $data
020      SubroutineContext: {CameFromInstPtr 1860, TriggerPointer } (type: SubroutineContext)

019      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=78, ParentScopeId=77, IsClosure=False
            local var $data is Variable with value = $data
            local var $fitness_fn is Variable with value = $fitness_fn
            local var $step_size is Variable with value = $step_size
            local var $next_data is Variable with value = $next_data
018      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=77, ParentScopeId=76, IsClosure=True
            local var $seek* is Variable with value = $seek*
            local var $best_neighbor* is Variable with value = $best_neighbor*
            local var $neighbors* is Variable with value = $neighbors*
            local var $infinity is Variable with value = $infinity
            local var $default_step_size is Variable with value = $default_step_size
017      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=76, ParentScopeId=0, IsClosure=True
016      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=0, ParentScopeId=-1, IsClosure=True
            local var $SAS is BoundVariable with value = SAS
            local var $GEAR is BoundVariable with value = GEAR
            local var $LEGS is BoundVariable with value = LEGS
            local var $CHUTES is BoundVariable with value = CHUTES
            local var $CHUTESSAFE is BoundVariable with value = CHUTESSAFE
            local var $LIGHTS is BoundVariable with value = LIGHTS
            local var $PANELS is BoundVariable with value = PANELS
            local var $RADIATORS is BoundVariable with value = RADIATORS
            local var $LADDERS is BoundVariable with value = LADDERS
            local var $BAYS is BoundVariable with value = BAYS
            local var $DEPLOYDRILLS is BoundVariable with value = DEPLOYDRILLS
            local var $DRILLS is BoundVariable with value = DRILLS
            local var $FUELCELLS is BoundVariable with value = FUELCELLS
            local var $ISRU is BoundVariable with value = ISRU
            local var $INTAKES is BoundVariable with value = INTAKES
            local var $BRAKES is BoundVariable with value = BRAKES
            local var $RCS is BoundVariable with value = RCS
            local var $ABORT is BoundVariable with value = ABORT
            local var $AG1 is BoundVariable with value = AG1
            local var $AG2 is BoundVariable with value = AG2
            local var $AG3 is BoundVariable with value = AG3
            local var $AG4 is BoundVariable with value = AG4
            local var $AG5 is BoundVariable with value = AG5
            local var $AG6 is BoundVariable with value = AG6
            local var $AG7 is BoundVariable with value = AG7
            local var $AG8 is BoundVariable with value = AG8
            local var $AG9 is BoundVariable with value = AG9
            local var $AG10 is BoundVariable with value = AG10
            local var $CONFIG is BoundVariable with value = CONFIG
            local var $ADDONS is BoundVariable with value = ADDONS
            local var $WHITE is BoundVariable with value = WHITE
            local var $BLACK is BoundVariable with value = BLACK
            local var $RED is BoundVariable with value = RED
            local var $GREEN is BoundVariable with value = GREEN
            local var $BLUE is BoundVariable with value = BLUE
            local var $YELLOW is BoundVariable with value = YELLOW
            local var $MAGENTA is BoundVariable with value = MAGENTA
            local var $PURPLE is BoundVariable with value = PURPLE
            local var $CYAN is BoundVariable with value = CYAN
            local var $GREY is BoundVariable with value = GREY
            local var $GRAY is BoundVariable with value = GRAY
            local var $DONOTHING is BoundVariable with value = DONOTHING
            local var $THROTTLE is BoundVariable with value = THROTTLE
            local var $STEERING is BoundVariable with value = STEERING
            local var $WHEELSTEERING is BoundVariable with value = WHEELSTEERING
            local var $WHEELTHROTTLE is BoundVariable with value = WHEELTHROTTLE
            local var $SASMODE is BoundVariable with value = SASMODE
            local var $NAVMODE is BoundVariable with value = NAVMODE
            local var $ALT is BoundVariable with value = ALT
            local var $ANGULARVELOCITY is BoundVariable with value = ANGULARVELOCITY
            local var $ENCOUNTER is BoundVariable with value = ENCOUNTER
            local var $ETA is BoundVariable with value = ETA
            local var $MISSIONTIME is BoundVariable with value = MISSIONTIME
            local var $OBT is BoundVariable with value = OBT
            local var $ORBIT is BoundVariable with value = ORBIT
            local var $TIME is BoundVariable with value = TIME
            local var $ACTIVESHIP is BoundVariable with value = ACTIVESHIP
            local var $STATUS is BoundVariable with value = STATUS
            local var $STAGE is BoundVariable with value = STAGE
            local var $SHIPNAME is BoundVariable with value = SHIPNAME
            local var $STEERINGMANAGER is BoundVariable with value = STEERINGMANAGER
            local var $NEXTNODE is BoundVariable with value = NEXTNODE
            local var $HASNODE is BoundVariable with value = HASNODE
            local var $ALLNODES is BoundVariable with value = ALLNODES
            local var $CORE is BoundVariable with value = CORE
            local var $SHIP is BoundVariable with value = SHIP
            local var $HEADING is BoundVariable with value = HEADING
            local var $PROGRADE is BoundVariable with value = PROGRADE
            local var $RETROGRADE is BoundVariable with value = RETROGRADE
            local var $FACING is BoundVariable with value = FACING
            local var $MAXTHRUST is BoundVariable with value = MAXTHRUST
            local var $AVAILABLETHRUST is BoundVariable with value = AVAILABLETHRUST
            local var $VELOCITY is BoundVariable with value = VELOCITY
            local var $GEOPOSITION is BoundVariable with value = GEOPOSITION
            local var $LATITUDE is BoundVariable with value = LATITUDE
            local var $LONGITUDE is BoundVariable with value = LONGITUDE
            local var $UP is BoundVariable with value = UP
            local var $NORTH is BoundVariable with value = NORTH
            local var $BODY is BoundVariable with value = BODY
            local var $ANGULARMOMENTUM is BoundVariable with value = ANGULARMOMENTUM
            local var $ANGULARVEL is BoundVariable with value = ANGULARVEL
            local var $MASS is BoundVariable with value = MASS
            local var $VERTICALSPEED is BoundVariable with value = VERTICALSPEED
            local var $SURFACESPEED is BoundVariable with value = SURFACESPEED
            local var $GROUNDSPEED is BoundVariable with value = GROUNDSPEED
            local var $AIRSPEED is BoundVariable with value = AIRSPEED
            local var $ALTITUDE is BoundVariable with value = ALTITUDE
            local var $APOAPSIS is BoundVariable with value = APOAPSIS
            local var $PERIAPSIS is BoundVariable with value = PERIAPSIS
            local var $SENSOR is BoundVariable with value = SENSOR
            local var $SRFPROGRADE is BoundVariable with value = SRFPROGRADE
            local var $SRFRETROGRADE is BoundVariable with value = SRFRETROGRADE
            local var $TARGET is BoundVariable with value = TARGET
            local var $HASTARGET is BoundVariable with value = HASTARGET
            local var $SESSIONTIME is BoundVariable with value = SESSIONTIME
            local var $VOLUME:NAME is BoundVariable with value = VOLUME:NAME
            local var $TERMINAL is BoundVariable with value = TERMINAL
            local var $KUNIVERSE is BoundVariable with value = KUNIVERSE
            local var $HOMECONNECTION is BoundVariable with value = HOMECONNECTION
            local var $CONTROLCONNECTION is BoundVariable with value = CONTROLCONNECTION
            local var $WARPMODE is BoundVariable with value = WARPMODE
            local var $WARP is BoundVariable with value = WARP
            local var $MAPVIEW is BoundVariable with value = MAPVIEW
            local var $CONSTANT is BoundVariable with value = CONSTANT
            local var $VERSION is BoundVariable with value = VERSION
            local var $SOLARPRIMEVECTOR is BoundVariable with value = SOLARPRIMEVECTOR
            local var $ARCHIVE is BoundVariable with value = ARCHIVE
            local var $Sun is BoundVariable with value = Sun
            local var $Kerbin is BoundVariable with value = Kerbin
            local var $Mun is BoundVariable with value = Mun
            local var $Minmus is BoundVariable with value = Minmus
            local var $Moho is BoundVariable with value = Moho
            local var $Eve is BoundVariable with value = Eve
            local var $Duna is BoundVariable with value = Duna
            local var $Ike is BoundVariable with value = Ike
            local var $Jool is BoundVariable with value = Jool
            local var $Laythe is BoundVariable with value = Laythe
            local var $Vall is BoundVariable with value = Vall
            local var $Bop is BoundVariable with value = Bop
            local var $Tylo is BoundVariable with value = Tylo
            local var $Gilly is BoundVariable with value = Gilly
            local var $Pol is BoundVariable with value = Pol
            local var $Dres is BoundVariable with value = Dres
            local var $Eeloo is BoundVariable with value = Eeloo
            local var $message* is Variable with value = $message*
            local var $startupfile is Variable with value = $startupfile
            local var $steering* is Variable with value = $steering*
            local var $throttle* is Variable with value = $throttle*
            local var $ascent* is Variable with value = $ascent*
            local var $insertion* is Variable with value = $insertion*
            local var $azimuth* is Variable with value = $azimuth*
            local var $ascent is Variable with value = $ascent
            local var $maneuver is Variable with value = $maneuver
            local var $hillclimb is Variable with value = $hillclimb
            local var $transfer is Variable with value = $transfer
            local var $interplanetary is Variable with value = $interplanetary
            local var $gtconstant is Variable with value = $gtconstant
            local var $myens is Variable with value = $myens
            local var $solid is Variable with value = $solid
            local var $apvel is Variable with value = $apvel
            local var $r is Variable with value = $r
            local var $sma is Variable with value = $sma
            local var $targetvel is Variable with value = $targetvel
            local var $ens is Variable with value = $ens
            local var $ensthr is Variable with value = $ensthr
            local var $ensisp is Variable with value = $ensisp
            local var $myengines is Variable with value = $myengines
            local var $data is Variable with value = $data
015      SubroutineContext: {CameFromInstPtr 2049, TriggerPointer } (type: SubroutineContext)

014      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=89, ParentScopeId=88, IsClosure=False
            local var $targetbody is Variable with value = $targetbody
            local var $targetpe is Variable with value = $targetpe
013      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=88, ParentScopeId=87, IsClosure=True
            local var $seek* is Variable with value = $seek*
            local var $startingdata* is Variable with value = $startingdata*
            local var $makenode* is Variable with value = $makenode*
            local var $removenodes* is Variable with value = $removenodes*
            local var $escapefit* is Variable with value = $escapefit*
            local var $transferfit* is Variable with value = $transferfit*
            local var $pefit* is Variable with value = $pefit*
            local var $closest_approach* is Variable with value = $closest_approach*
            local var $slope_at* is Variable with value = $slope_at*
            local var $separation_at* is Variable with value = $separation_at*
            local var $transfers_to* is Variable with value = $transfers_to*
            local var $infinity is Variable with value = $infinity
012      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=87, ParentScopeId=0, IsClosure=True
011      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=0, ParentScopeId=-1, IsClosure=True
            local var $SAS is BoundVariable with value = SAS
            local var $GEAR is BoundVariable with value = GEAR
            local var $LEGS is BoundVariable with value = LEGS
            local var $CHUTES is BoundVariable with value = CHUTES
            local var $CHUTESSAFE is BoundVariable with value = CHUTESSAFE
            local var $LIGHTS is BoundVariable with value = LIGHTS
            local var $PANELS is BoundVariable with value = PANELS
            local var $RADIATORS is BoundVariable with value = RADIATORS
            local var $LADDERS is BoundVariable with value = LADDERS
            local var $BAYS is BoundVariable with value = BAYS
            local var $DEPLOYDRILLS is BoundVariable with value = DEPLOYDRILLS
            local var $DRILLS is BoundVariable with value = DRILLS
            local var $FUELCELLS is BoundVariable with value = FUELCELLS
            local var $ISRU is BoundVariable with value = ISRU
            local var $INTAKES is BoundVariable with value = INTAKES
            local var $BRAKES is BoundVariable with value = BRAKES
            local var $RCS is BoundVariable with value = RCS
            local var $ABORT is BoundVariable with value = ABORT
            local var $AG1 is BoundVariable with value = AG1
            local var $AG2 is BoundVariable with value = AG2
            local var $AG3 is BoundVariable with value = AG3
            local var $AG4 is BoundVariable with value = AG4
            local var $AG5 is BoundVariable with value = AG5
            local var $AG6 is BoundVariable with value = AG6
            local var $AG7 is BoundVariable with value = AG7
            local var $AG8 is BoundVariable with value = AG8
            local var $AG9 is BoundVariable with value = AG9
            local var $AG10 is BoundVariable with value = AG10
            local var $CONFIG is BoundVariable with value = CONFIG
            local var $ADDONS is BoundVariable with value = ADDONS
            local var $WHITE is BoundVariable with value = WHITE
            local var $BLACK is BoundVariable with value = BLACK
            local var $RED is BoundVariable with value = RED
            local var $GREEN is BoundVariable with value = GREEN
            local var $BLUE is BoundVariable with value = BLUE
            local var $YELLOW is BoundVariable with value = YELLOW
            local var $MAGENTA is BoundVariable with value = MAGENTA
            local var $PURPLE is BoundVariable with value = PURPLE
            local var $CYAN is BoundVariable with value = CYAN
            local var $GREY is BoundVariable with value = GREY
            local var $GRAY is BoundVariable with value = GRAY
            local var $DONOTHING is BoundVariable with value = DONOTHING
            local var $THROTTLE is BoundVariable with value = THROTTLE
            local var $STEERING is BoundVariable with value = STEERING
            local var $WHEELSTEERING is BoundVariable with value = WHEELSTEERING
            local var $WHEELTHROTTLE is BoundVariable with value = WHEELTHROTTLE
            local var $SASMODE is BoundVariable with value = SASMODE
            local var $NAVMODE is BoundVariable with value = NAVMODE
            local var $ALT is BoundVariable with value = ALT
            local var $ANGULARVELOCITY is BoundVariable with value = ANGULARVELOCITY
            local var $ENCOUNTER is BoundVariable with value = ENCOUNTER
            local var $ETA is BoundVariable with value = ETA
            local var $MISSIONTIME is BoundVariable with value = MISSIONTIME
            local var $OBT is BoundVariable with value = OBT
            local var $ORBIT is BoundVariable with value = ORBIT
            local var $TIME is BoundVariable with value = TIME
            local var $ACTIVESHIP is BoundVariable with value = ACTIVESHIP
            local var $STATUS is BoundVariable with value = STATUS
            local var $STAGE is BoundVariable with value = STAGE
            local var $SHIPNAME is BoundVariable with value = SHIPNAME
            local var $STEERINGMANAGER is BoundVariable with value = STEERINGMANAGER
            local var $NEXTNODE is BoundVariable with value = NEXTNODE
            local var $HASNODE is BoundVariable with value = HASNODE
            local var $ALLNODES is BoundVariable with value = ALLNODES
            local var $CORE is BoundVariable with value = CORE
            local var $SHIP is BoundVariable with value = SHIP
            local var $HEADING is BoundVariable with value = HEADING
            local var $PROGRADE is BoundVariable with value = PROGRADE
            local var $RETROGRADE is BoundVariable with value = RETROGRADE
            local var $FACING is BoundVariable with value = FACING
            local var $MAXTHRUST is BoundVariable with value = MAXTHRUST
            local var $AVAILABLETHRUST is BoundVariable with value = AVAILABLETHRUST
            local var $VELOCITY is BoundVariable with value = VELOCITY
            local var $GEOPOSITION is BoundVariable with value = GEOPOSITION
            local var $LATITUDE is BoundVariable with value = LATITUDE
            local var $LONGITUDE is BoundVariable with value = LONGITUDE
            local var $UP is BoundVariable with value = UP
            local var $NORTH is BoundVariable with value = NORTH
            local var $BODY is BoundVariable with value = BODY
            local var $ANGULARMOMENTUM is BoundVariable with value = ANGULARMOMENTUM
            local var $ANGULARVEL is BoundVariable with value = ANGULARVEL
            local var $MASS is BoundVariable with value = MASS
            local var $VERTICALSPEED is BoundVariable with value = VERTICALSPEED
            local var $SURFACESPEED is BoundVariable with value = SURFACESPEED
            local var $GROUNDSPEED is BoundVariable with value = GROUNDSPEED
            local var $AIRSPEED is BoundVariable with value = AIRSPEED
            local var $ALTITUDE is BoundVariable with value = ALTITUDE
            local var $APOAPSIS is BoundVariable with value = APOAPSIS
            local var $PERIAPSIS is BoundVariable with value = PERIAPSIS
            local var $SENSOR is BoundVariable with value = SENSOR
            local var $SRFPROGRADE is BoundVariable with value = SRFPROGRADE
            local var $SRFRETROGRADE is BoundVariable with value = SRFRETROGRADE
            local var $TARGET is BoundVariable with value = TARGET
            local var $HASTARGET is BoundVariable with value = HASTARGET
            local var $SESSIONTIME is BoundVariable with value = SESSIONTIME
            local var $VOLUME:NAME is BoundVariable with value = VOLUME:NAME
            local var $TERMINAL is BoundVariable with value = TERMINAL
            local var $KUNIVERSE is BoundVariable with value = KUNIVERSE
            local var $HOMECONNECTION is BoundVariable with value = HOMECONNECTION
            local var $CONTROLCONNECTION is BoundVariable with value = CONTROLCONNECTION
            local var $WARPMODE is BoundVariable with value = WARPMODE
            local var $WARP is BoundVariable with value = WARP
            local var $MAPVIEW is BoundVariable with value = MAPVIEW
            local var $CONSTANT is BoundVariable with value = CONSTANT
            local var $VERSION is BoundVariable with value = VERSION
            local var $SOLARPRIMEVECTOR is BoundVariable with value = SOLARPRIMEVECTOR
            local var $ARCHIVE is BoundVariable with value = ARCHIVE
            local var $Sun is BoundVariable with value = Sun
            local var $Kerbin is BoundVariable with value = Kerbin
            local var $Mun is BoundVariable with value = Mun
            local var $Minmus is BoundVariable with value = Minmus
            local var $Moho is BoundVariable with value = Moho
            local var $Eve is BoundVariable with value = Eve
            local var $Duna is BoundVariable with value = Duna
            local var $Ike is BoundVariable with value = Ike
            local var $Jool is BoundVariable with value = Jool
            local var $Laythe is BoundVariable with value = Laythe
            local var $Vall is BoundVariable with value = Vall
            local var $Bop is BoundVariable with value = Bop
            local var $Tylo is BoundVariable with value = Tylo
            local var $Gilly is BoundVariable with value = Gilly
            local var $Pol is BoundVariable with value = Pol
            local var $Dres is BoundVariable with value = Dres
            local var $Eeloo is BoundVariable with value = Eeloo
            local var $message* is Variable with value = $message*
            local var $startupfile is Variable with value = $startupfile
            local var $steering* is Variable with value = $steering*
            local var $throttle* is Variable with value = $throttle*
            local var $ascent* is Variable with value = $ascent*
            local var $insertion* is Variable with value = $insertion*
            local var $azimuth* is Variable with value = $azimuth*
            local var $ascent is Variable with value = $ascent
            local var $maneuver is Variable with value = $maneuver
            local var $hillclimb is Variable with value = $hillclimb
            local var $transfer is Variable with value = $transfer
            local var $interplanetary is Variable with value = $interplanetary
            local var $gtconstant is Variable with value = $gtconstant
            local var $myens is Variable with value = $myens
            local var $solid is Variable with value = $solid
            local var $apvel is Variable with value = $apvel
            local var $r is Variable with value = $r
            local var $sma is Variable with value = $sma
            local var $targetvel is Variable with value = $targetvel
            local var $ens is Variable with value = $ens
            local var $ensthr is Variable with value = $ensthr
            local var $ensisp is Variable with value = $ensisp
            local var $myengines is Variable with value = $myengines
            local var $data is Variable with value = $data
010      SubroutineContext: {CameFromInstPtr 203, TriggerPointer } (type: SubroutineContext)

009      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=6, ParentScopeId=5, IsClosure=False
008      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=5, ParentScopeId=0, IsClosure=False
007      SubroutineContext: {CameFromInstPtr 22, TriggerPointer } (type: SubroutineContext)

006      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=-999, ParentScopeId=0, IsClosure=False
            local var $runonce is Variable with value = $runonce
            local var $filename is Variable with value = $filename
            local var $entrypoint is Variable with value = $entrypoint
005      SubroutineContext: {CameFromInstPtr 73, TriggerPointer } (type: SubroutineContext)

004      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=2, ParentScopeId=0, IsClosure=True
003      SubroutineContext: {CameFromInstPtr 22, TriggerPointer } (type: SubroutineContext)

002      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=-999, ParentScopeId=0, IsClosure=False
            local var $runonce is Variable with value = $runonce
            local var $filename is Variable with value = $filename
            local var $entrypoint is Variable with value = $entrypoint
001      SubroutineContext: {CameFromInstPtr 32, TriggerPointer } (type: SubroutineContext)

000      kOS.Safe.Execution.VariableScope (type: VariableScope)

          ScopeId=1, ParentScopeId=0, IsClosure=False

 

Link to comment
Share on other sites

It's a script error in your code.  Your code is written to assume the variable called 'data' is an array, because it's trying to get data[0].

But data isn't an array.  It's a single number. 

When you run this:

set data to hillclimb["seek"](data, transferFit(targetBody), 1).

your hillclimb() function is returning a single number, not a list of numbers.

 

Link to comment
Share on other sites

13 hours ago, Steven Mading said:

It's a script error in your code.  Your code is written to assume the variable called 'data' is an array, because it's trying to get data[0].

But data isn't an array.  It's a single number. 

When you run this:


set data to hillclimb["seek"](data, transferFit(targetBody), 1).

your hillclimb() function is returning a single number, not a list of numbers.

 

Here's my hill-climbing library.

// Hillclimb Algorithm Library
// Kevin Gisi
// http://youtube.com/gisikw

{
  local INFINITY is 2^64.
  local DEFAULT_STEP_SIZE is 1.

  global hillclimb is lex(
    "version", "0.1.0",
    "seek", seek@
  ).

  function seek {
    parameter data, fitness_fn, step_size is DEFAULT_STEP_SIZE.
    local next_data is best_neighbor(data, fitness_fn, step_size).
    until fitness_fn(next_data) <= fitness_fn(data) {
      set data to next_data.
      set next_data to best_neighbor(data, fitness_fn, step_size).
    }
    return data.
  }

  function best_neighbor {
    parameter data, fitness_fn, step_size.
    local best_fitness is -INFINITY.
    local best is 0.
    for neighbor in neighbors(data, step_size) {
      local fitness is fitness_fn(neighbor).
      if fitness > best_fitness {
        set best to neighbor.
        set best_fitness to fitness.
      }
    }
    return best. // Returns a list
  }

  function neighbors {
    parameter data, step_size, results is list().
    for i in range(0, data:length) {
      local increment is data:copy.
      local decrement is data:copy.
      set increment[i] to increment[i] + step_size.
      set decrement[i] to decrement[i] - step_size.
      results:add(increment).
      results:add(decrement).
    }
    return results. // Returns a list of lists
  }
}

 

Link to comment
Share on other sites

I'm not going to walk through your whole code.

Just print out the value of 'data' immediately prior to the line that complains.  Just before this:

local t is data[0].

do this:
 

print "data is type: " + data:typename().
print "data is value: " + data.

and see what data really is.  It's not what you think it is.

Link to comment
Share on other sites

16 minutes ago, Steven Mading said:

I'm not going to walk through your whole code.

Just print out the value of 'data' immediately prior to the line that complains.  Just before this:


local t is data[0].

do this:
 


print "data is type: " + data:typename().
print "data is value: " + data.

and see what data really is.  It's not what you think it is.

Thanks, I'll do that.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...