Jump to content

[kOS] Build your own MechJeb!


Recommended Posts

So inspired by Thrfoot's automated mission challenge, which I also discovered kOS through, I came up with this little challenge.

Simple enough, get a vessel of your design into a stable orbit around Kerbin, without using any input beyond typing out the execution command line at the beginning, and do it in the most (delta-v) efficient manner possible. It's not *quite* mechjeb, but it's a foundation!

RULES:

1. No mods that directly affect gameplay aside from kOS itself. Alternatively, say which gameplay-affecting mods you used, and that'll be fine too.

1a. You're gonna want to have kOS, obviously (get it here), and another pretty-much-required mod for this is Kerbal Engineer, as you need to know your (vacuum) delta-v before you launch, and after you're in orbit.

2. No user input! The only thing you can do is at the beginning of the launch, when you open up the command line, copy the program to the ship, and run it.

3. Your final orbit must have an apoapsis and a periapsis around Kerbin, and both must be outside Kerbin's atmosphere (that is, 69,078 metres above sea level).

4. You must have screenshots that show your delta-v from inside the hangar (Engineer shows your in-atmosphere delta-v when in flight mode), and your delta-v after achieving orbit, as well as proof that at least your periapsis is outside the atmosphere.

Aside from that I can't think of any other restrictions. Your ship can be as large as you like, as complex or simple as you like, and can operate whichever way you like. I'd be impressed to see a robotic spaceplane, myself.

Your score is the difference between your hangar delta-v and your orbital delta-v at the end, so obviously the lower the better. Also while this isn't required, it'd be super nice for you to post your code alongside your screenshots, help other people figure out the basics of the language. Maybe I can learn a thing or two as well.

And it wouldn't be a challenge if I didn't get in on it myself first, now would it?

idQeiLG.png

Starting delta-v: 4,855 m/s (I play it safe alright)

VKBGtN6.png

GUCuw6M.png

GhxPkNG.png

SjTT7TX.png

jR2S77f.png

Final delta-v: 282 m/s

So I have a score of 4,573 m/s.

And of course, here's my code. No comments because who needs good style right?

lock STEERING to UP.
lock THROTTLE to 1.
declare TermVel.
declare Speed.

until APOAPSIS > 75000
{
wait 0.01.
if ALTITUDE < 10000
{
set TermVel to 10 * ((1250 * 6.647 * (10^(-11)) * (5.292 * 10^(22))) / ( (1.2231 * 2.718^(-1 * ALTITUDE / 5000) * 101.33) * (600000 + ALTITUDE)^(2)))^0.5.
if VERTICALSPEED > TermVel and THROTTLE > 0.8
{
lock THROTTLE to THROTTLE - 0.01.
}.
if VERTICALSPEED < TermVel * 0.99 and THROTTLE != 1
{
lock THROTTLE to THROTTLE + 0.01.
}.
}.

if STAGE:LiquidFuel = 0
{
stage.
}.
if ALTITUDE > 10000 and ALTITUDE < 15000
{
lock THROTTLE to 1.
lock STEERING to HEADING 90 by 60.
}.
if ALTITUDE > 15000 and ALTITUDE < 20000
{
lock THROTTLE to 1.
lock STEERING to HEADING 90 by 30.
}.
if ALTITUDE > 20000
{
lock THROTTLE to 1.
lock STEERING to HEADING 90 by 15.
}.

}.

lock THROTTLE to 0.

print "Apoapsis of 75km achieved".

lock STEERING to HEADING 90 by 0.

wait until ETA:APOAPSIS < 4.
wait 0.01.

lock THROTTLE to 1.

until PERIAPSIS > 70000
{
if STAGE:LiquidFuel = 0
{
stage.
}
}.

lock THROTTLE to 0.

print "Launch Complete...".

LEADERBOARD

(1). adammada, -434 m/s (Maybe? Some staging shenanigans)

1. Bobnova, 4413 m/s

2. Enigma179: 4,573 m/s

Edited by Enigma179
Link to comment
Share on other sites

Mine isn't nearly as professional as yours, but it functions decently.

Scattering a few stage commands through it will make it work with other ships too, I used something very similar to get to the Mun for the other challenge.

Anyway, here's the album:

Javascript is disabled. View full album

Starting D/V: 5247.

Orbit D/V: 834.

Total D/V used: 4413.

For giggles I tried your program copy/pasted too, it left me with 858 D/V remaining.

Link to comment
Share on other sites



Starting D/V: 1192
Orbit D/V: 1626
Total D/V used: -434 . I gained 434 D/V. So i'm winner now :D.




Your ship can be as large as you like, as complex or simple as you like, and can operate whichever way you like.

No cheating, just turbojet engine...
Link to comment
Share on other sites

Its all by the rules, so you should probably alter rules. Solutions:

a) Ban TurboJet engines

B) Provide .craft so it will become purely kOS contest

c) Use other method of counting used delta-V. Once MechJeb had "used delta-V" stat, I don't know if it has one now.

Link to comment
Share on other sites

Example of another flavor of the same bug: one of these has rather of a lot more DV than the other, but they're listed the same.

Nope. In your example everything works as it should. Look at your staging. First stage is to ditch fuel tanks, second stage is fire engine with central tank.

I think that this is not bug in KE, its just TurboJet ISP wchich is changing, so KE estimations are not correct.

Link to comment
Share on other sites

Please help me to understand what "ground" delta-V means.

I only used Kerbal Engineer very briefly so I don't know a lot about it.

What is the "delta V on the ground" readout that you're referring to and what does it actually mean? It can't be the delta V a maneuver takes since it doesn't know what maneuvers you'll be doing yet.

Is it meant to be the maximum amount of delta-V you could possibly attain with the remaining fuel on board? If so I assume it needs to make lots of assumptions to make that calculation since it varies depending on how you use that fuel, and I'd like to know what those assumptions are.

These are the things I'd like to know what the assumptions the measurement is based on are:

ISP: ISP varies depending on how long you spend in atmosphere, because sea level ISP is not the same as vacuum ISP. What assumption is KE making about this when it comes up with the figure?

Drag: Thicker air gives you less delta-V return for the same fuel burned, so since KE doesn't know my flight path what is it assuming about this? Is it just giving me what the delta-V would be in a vacuum?

Which fuel goes to which engine: Various complex staging techniques can make it hard to calculate which fuel will be ending up in which engine when. If I have yellow fuel hoses doing strange things, does KE calculate the delta-V right?

Does it make presumptions about when I'll be hitting the spacebar to stage? Since both the remaining mass and the remaining engines depend on staging, does it take this into account or does it presume a simple case where the length of the burn occurs all-in-one-stage for the delta-V calculation?

Link to comment
Share on other sites

It's in the rules:

You must have screenshots that show your delta-v from inside the hangar (Engineer shows your in-atmosphere delta-v when in flight mode), and your delta-v after achieving orbit, as well as proof that at least your periapsis is outside the atmosphere.

Hanger DV, orbit DV.

Link to comment
Share on other sites

It's in the rules:

Hanger DV, orbit DV.

Is the challenge only supposed to be for spaceplanes? It's a bit of a pain to get a rocket design into the hangar instead of the the VAB.

Secondly, that really doesn't answer all the questions. Vacuum versus Atmosphere measure was just one question.

Link to comment
Share on other sites

When you're in the hanger/VAB, it shows vacuum. How hard is it to understand that you take what KE shows in the hanger/vab and subtract what KE shows in orbit?

Trying to optimize a thing requires knowing how it's being measured. Otherwise it's just guesswork. Knowing how to count the score doesn't mean knowing what tactics would work to make the score better. That requires knowing how those numbers are being derived.

Edited by Steven Mading
Link to comment
Share on other sites

Knowing how to count the score tells you exactly which numbers are used. If you know which numbers are used, surely you can figure out where they come from.

Think, man, think.

While it is possible to reverse engineer something to work it out the meaning of a number, by trying again and again and again using lots of trials with slightly different setups and recording the results until a pattern emerges, it's also an utter waste of time if it's already known. In this case it must be already known to at least some people, since the number is the result of humans making software. Take your own advice and think instead of being condescending.

Edited by Steven Mading
Link to comment
Share on other sites

Kind of asking in the wrong place if you want to know about the inner workings of KE then, aren't you?

If I had to hazard a guess, I would say it probably uses the vacuum DV calculation. The one with ISP and fuel and vehicle weight.

Link to comment
Share on other sites

What is the "delta V on the ground" readout that you're referring to and what does it actually mean? It can't be the delta V a maneuver takes since it doesn't know what maneuvers you'll be doing yet.

Is it meant to be the maximum amount of delta-V you could possibly attain with the remaining fuel on board?

Yes, essentially. In simple cases without fuel crossfeed or parallel staging, it reduces to just applying the rocket equation on each stage.

ISP: ISP varies depending on how long you spend in atmosphere, because sea level ISP is not the same as vacuum ISP. What assumption is KE making about this when it comes up with the figure?

KE assumes constant Isp for each engine, either vacuum or atmospheric. Hence the distinction between "vacuum dV" and "atmospheric dV."

Drag: Thicker air gives you less delta-V return for the same fuel burned, so since KE doesn't know my flight path what is it assuming about this? Is it just giving me what the delta-V would be in a vacuum?

Drag losses are a function of trajectory, for a fixed design. A given design has an inherent max delta-V capacity, your trajectory and throttle settings determine how far you can get with that delta-V capacity.

Which fuel goes to which engine: Various complex staging techniques can make it hard to calculate which fuel will be ending up in which engine when. If I have yellow fuel hoses doing strange things, does KE calculate the delta-V right?

For the most part, yes. When there is fuel cross-feed, KE does a fuel flow simulation to determine which engines draw from which tanks during each stage. When there are multiple types of engines, the overall weighted effective Isp depends on the combinations of engines that are burning, and this can change at each stage.

Does it make presumptions about when I'll be hitting the spacebar to stage? Since both the remaining mass and the remaining engines depend on staging, does it take this into account or does it presume a simple case where the length of the burn occurs all-in-one-stage for the delta-V calculation?

Yes, it assumes a best case where you drop each stage at the exact instant the fuel flow simulation predicts it will run out of fuel.

Edited by tavert
Link to comment
Share on other sites

Kind of asking in the wrong place if you want to know about the inner workings of KE then, aren't you?

Well, I don't consider a number the mod is communicating to the user to be "inner workings". If it's being told to the user the presumption is that the user is supposed to know what it represents and I assumed people who'd been users of it all along would know, especially if it's being used to judge the contest, thus the question. Wanting to know the algorithm used to calculate it would be "inner workings", but just wanting to know what it actually means isn't.

(EDIT: ninja post by tavert while I was composing, rendering most of what I said after this moot).

Thank you for the relevant answers, tavert. The only remaining question is whether it just ignores the gravity well altogether when making the calculation. (When climbing from a gravity well into orbit you can't get nearly as much dV as you could when already in orbit, because when already in orbit you can treat the burn as if it occurred at a single instant in time, but when climbing that assumption breaks down and the fact that you spent a lot of that burn fighting against gravity as you slowly got up to speed causes "wasted" dV, and in effect this challenge is all about trying to minimize that as much as possible.)

So is it saying if we pretended there was no wastage from slowly fighting a gravity well and the craft was just floating freely in interstellar space all by itself, this would be the dV it could achieve, or is it saying its the dV it would get from an optimal gravity turn, which is less than that?

Edited by Steven Mading
Link to comment
Share on other sites

Thank you for the relevant answers, tavert. The only remaining question is whether it just ignores the gravity well altogether when making the calculation. (When climbing from a gravity well into orbit you can't get nearly as much dV as you could when already in orbit, because when already in orbit you can treat the burn as if it occurred at a single instant in time, but when climbing that assumption breaks down and the fact that you spent a lot of that burn fighting against gravity as you slowly got up to speed causes "wasted" dV, and in effect this challenge is all about trying to minimize that as much as possible.)

So is it saying if we pretended there was no wastage from slowly fighting a gravity well and the craft was just floating freely in interstellar space all by itself, this would be the dV it could achieve, or is it saying its the dV it would get from an optimal gravity turn, which is less than that?

HTH. Yes, KE tells you "design dV capacity" before taking into account any losses due to gravity, atmospheric drag, or steering (non-prograde thrust). I forget whether KE will actually measure those individual losses while in flight, I know MechJeb does. Neither KE nor MechJeb do any simulations of the ascent performance of your design, or optimization of gravity turns, etc. The "design dV capacity" just tells you that if you were to burn through all of your craft's fuel (in a vacuum for vac dV, or at constant sea-level ambient pressure for atmospheric dV) and stage immediately when you should, what will be the result of integrating gross engine thrust divided by total craft mass over time.

Edited by tavert
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...