Jump to content

[Win|Mac|Linux (Java)] Cost balancer


Recommended Posts

kwUQSsW.png

Ok, that image is quite unspectacular, but there really is no GUI and threads without images don't really do all that well...

A what now?

Cost Balancer. For lack of a better term. It goes through your part list and tries to adjust the item cost to a somewhat balanced value.

How?

The script loads your part.cfg files, parses them, looks for stuff like stored resources, engine type & power, ISP etc. and after some magic (basic math) it conjures up a new cost.

If the cost changed as a result, it backs up your old part.cfg file and replaces the old one.

How well are those costs balanced?

I did not do a lot of playtesting with it, but except from ion engines being a bit on the expensive side the prices "feel" ok to me.

They are roughly in line with stock ksp prices, lower volume resoruce tanks are a bit more expensive while higher volume tanks don't get as rediciously expensive quite so fast.

Why?

To go hand-in-hand with my other app, the KSP Campaign manager. Trying to build cheap rockets to get more funds gets stale very fast if almost every modded part only has placeholder costs.

Sadly, I can not just redistribute part.cfg files with balanced prices because most mod licenses won't allow that.

I have no idea what to do with the stuff I just downloaded

It's not that difficult, really. Just extract the folder in the archive into your KSP folder.

Then open a command line, terminal or shell window depending on your OS and go to "[ksp_folder]/Cost Balancer" (cd "[path]" should usually do the trick).

Now for the tricky part. Type

java -jar "ksp cost balancer.jar"

and hit enter. A few seconds later you should get some feedback as to what is happening.

I am getting a bunch of errors at the end, what's wrong?

There will most likely be a bunch of errors at the end. The parse can currently not handle 2 things:

Syntactically incorrect part files (not matching amount of curly braces e.g.), and

parts that have lines like "a, b, somestuff".

There's not much I can do about the first issue (seriously modders, get your syntax right). The second issue I'll fix some other time.

There really should not be that many engine/tank parts that are affected.

I've tested the programm on mac and windows, but it was quite a ride getting it to work on windows.. so if it's not working for you just post your problems and I'll get back to you.

Source, license, credits?

The source can be found at Github and the programm is licensed under the MIT license.

Again, thanks go out to my brother wo helped me a lot with the parser and general questions regarding jruby.

Feel free to give me feedback about the resulting prices, source code, parts that fail to parse etc.

For those brave enough to read all of this, here's the download link again: Download (via mega)

Edited by MaliciousMuffin
Link to comment
Share on other sites

The cost and mass of tanks could be calculated easily by a formula: mass=(surface area * material mass/unit area = dry mass + volume * fuel mass/unit volume = full mass)

OK, my math syntax isn't entirely right, but I think you can figure out what I'm talking about. More expensive materials could have superior strength to weight ratios, thus allowing you to construct lighter, stronger tanks for an additional cost.

I don't know if this was along the lines of what you were thinking. It might be more relevant to the tank generator app, but it's a way to think about how engineering decisions affect the cost of a part.

Link to comment
Share on other sites

I don't know if this was along the lines of what you were thinking. It might be more relevant to the tank generator app, but it's a way to think about how engineering decisions affect the cost of a part.

I gave something similar to that equation to Muffin, and he probably used it.

((mass−drymass)∗dpkg) ∗ ucost+(drymass ∗mcost)

dkpg = desnity per kilo

ucost = cost of fuel unit

mcost = cost of metal

Link to comment
Share on other sites

The cost and mass of tanks could be calculated easily by a formula: mass=(surface area * material mass/unit area = dry mass + volume * fuel mass/unit volume = full mass)

OK, my math syntax isn't entirely right, but I think you can figure out what I'm talking about. More expensive materials could have superior strength to weight ratios, thus allowing you to construct lighter, stronger tanks for an additional cost.

I don't know if this was along the lines of what you were thinking. It might be more relevant to the tank generator app, but it's a way to think about how engineering decisions affect the cost of a part.

The problem with a formula like the above is, that there is no information regarding the size (surface area, diameter, length, volume) in the actual part config file. Basically I've got part mass, fuel amount and density and maximum fuel amount to work with.

I gave something similar to that equation to Muffin, and he probably used it.

((mass−drymass)∗dpkg) ∗ ucost+(drymass ∗mcost)

dkpg = desnity per kilo

ucost = cost of fuel unit

mcost = cost of metal

There's a similar problem with this. You can't really assign anything but a flat metal cost because there is no information in the file what the part is made of. And actually, the formula is a bit backwards. Parts get more valuable the higher their fuel/mass ratio is. A part that weights 10 when it's filled up and 1 when it's empty is preferable over one that weights 10 when it's full and 5 when it's empty.

Linear scaling is not in line with the larger vanilla fuel tanks, either.

The formula I use is:

Fuel * [5,7 + log10(Fuel) * (FullMass/EmptyMass - 7)] * FuelCost / 3

That is more in line with the overproportional scaling of vanilla tank costs for larger volumes and makes parts with a mass ratio (FullMass/EmptyMass) of 10 about 9%-10% more expensive than parts with a ratio of 9.

Link to comment
Share on other sites

There's a similar problem with this. You can't really assign anything but a flat metal cost because there is no information in the file what the part is made of. And actually, the formula is a bit backwards. Parts get more valuable the higher their fuel/mass ratio is. A part that weights 10 when it's filled up and 1 when it's empty is preferable over one that weights 10 when it's full and 5 when it's empty.

Linear scaling is not in line with the larger vanilla fuel tanks, either.

Okay, lets try and fix this. We can solve the first issue with:

((mass−drymass)∗dpkg) ∗ ucost + (drymass ∗mcost)

But, as you said, that this is more suited towards the density of the units. But think about it. The ∗dpkg is for calculating the cost per unit. If you want to get the cost per kilo of the unit, you do this:

((mass−drymass)∗dpkg) ∗ ucost

So basically, it calculates how much kilograms of fuel there is multiplied by the density of each unit per kilo to return the amount of units in the tank. Then it multiplies that by the cost of each unit.

Edited by ROFLCopter64bit
Link to comment
Share on other sites

Not sure why it's failing, but on W7 x64 i'm getting;


E:\Steam\steamapps\common\Kerbal Space Program\Cost Balancer>java -jar "ksp cost balancer.jar"
no such file to load -- gempack
Creating backup dir in backup/2013-05-08_07-19-23
Exception in thread "main" org.jruby.exceptions.RaiseException: (Errno::ESRCH) E:\Steam\steamapps\common\Kerbal%20Space%20Program\Cost%20Balancer\backup
at org.jruby.RubyDir.mkdir(org/jruby/RubyDir.java:577)
at RUBY.prepare_backup(file:E:/Steam/steamapps/common/Kerbal Space Program/Cost Balancer/ksp cost balancer.jar!/ksp-cfg.rb:65)
at RUBY.initialize(file:E:/Steam/steamapps/common/Kerbal Space Program/Cost Balancer/ksp cost balancer.jar!/ksp-cfg.rb:13)
at RUBY.(root)(file:/E:/Steam/steamapps/common/Kerbal Space Program/Cost Balancer/ksp cost balancer.jar!/main.rb:19)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1027)
at RUBY.(root)(jar:file:/E:/Steam/steamapps/common/Kerbal%20Space%20Program/Cost%20Balancer/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1)
at RUBY.require(jar:file:/E:/Steam/steamapps/common/Kerbal%20Space%20Program/Cost%20Balancer/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)");

Link to comment
Share on other sites

Not sure why it's failing, but on W7 x64 i'm getting;


E:\Steam\steamapps\common\Kerbal Space Program\Cost Balancer>java -jar "ksp cost balancer.jar"
no such file to load -- gempack
Creating backup dir in backup/2013-05-08_07-19-23
Exception in thread "main" org.jruby.exceptions.RaiseException: (Errno::ESRCH) E:\Steam\steamapps\common\Kerbal%20Space%20Program\Cost%20Balancer\backup
at org.jruby.RubyDir.mkdir(org/jruby/RubyDir.java:577)
at RUBY.prepare_backup(file:E:/Steam/steamapps/common/Kerbal Space Program/Cost Balancer/ksp cost balancer.jar!/ksp-cfg.rb:65)
at RUBY.initialize(file:E:/Steam/steamapps/common/Kerbal Space Program/Cost Balancer/ksp cost balancer.jar!/ksp-cfg.rb:13)
at RUBY.(root)(file:/E:/Steam/steamapps/common/Kerbal Space Program/Cost Balancer/ksp cost balancer.jar!/main.rb:19)
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1027)
at RUBY.(root)(jar:file:/E:/Steam/steamapps/common/Kerbal%20Space%20Program/Cost%20Balancer/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1)
at RUBY.require(jar:file:/E:/Steam/steamapps/common/Kerbal%20Space%20Program/Cost%20Balancer/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)");

Hm, seems to be a problem with a certain function call of JRuby that does not work on windows if there are spaces in the path to your game.

I did not really think of testing that, but I'll try and fix it in the next few hours.

Link to comment
Share on other sites

I'm trying to run this file and well, I'm having a swell time trying to figure it out. I'm not a programmer by any respect and have never grown up to use the command console at all, so I'm quite literally befuddled at the part to run the .Jar file. The farthest I've gotten was identifying the containing folder, running the jar file with the java line gives me an non recognized input error. Could you school me on how the command console works so I can use this plugin correctly? :P

Also, do you plan on making this an executable file in future updates, for those of us who never learned the command console? The easier accessibility may draw in more users to this item as well as the campaign!

Link to comment
Share on other sites

Also, do you plan on making this an executable file in future updates, for those of us who never learned the command console? The easier accessibility may draw in more users to this item as well as the campaign!

I'm using a modification of my Carbon AutoAnalyzer. It's currently in private use, but I can modify it for public use. It also uses plagurised my own formulae, and I plan to add customization to the way it calculates for flexibilty.

Link to comment
Share on other sites

I'm trying to run this file and well, I'm having a swell time trying to figure it out. I'm not a programmer by any respect and have never grown up to use the command console at all, so I'm quite literally befuddled at the part to run the .Jar file. The farthest I've gotten was identifying the containing folder, running the jar file with the java line gives me an non recognized input error. Could you school me on how the command console works so I can use this plugin correctly? :P

Ok, first of all: do you have java 1.7 installed? Java is used by quite a few applications and it seemed like a reasonable dependency.

As to the command line: I take it you are using windows?

if so, open it my pressing "windows+r" and then type

cmd

(i guess you figured that step out on your own alraedy but for completeness sake..)

In the code block, you'll need to replace "[KSP folder]" with your ksp folder, for example "c:\Program Files\Steam\Steamapss\common\kerbal space program". If that path contains spaces, wrap it in ".

"Cost Balancer" will need to be replaced with the cost balancer folder name inside your game folder.

cd "[KSP FOLDER]"
cd "Cost Balancer"
java -jar "ksp cost balancer.jar"

If that does not work, try

java -version

And post here what it says

As to your other question:

Also, do you plan on making this an executable file in future updates, for those of us who never learned the command console? The easier accessibility may draw in more users to this item as well as the campaign

Not at the moment, sorry. I'm pretty swamped with learning for college right now and I'd rather concentrate on the website than on this tool.

Link to comment
Share on other sites

If you installed Java 7 correctly, it should automatically have set up Windows properly, meaning that executable .jar files are actually runnable the very same way as every other .exe . Just double click it (this does the "java -jar" automatically on the file). If this doesn't work, your registry class entry for .jarfile is wrong and should be fixed:

How to fix the registry:

1: Win+R to open the run menu

2: Type "regedit" (without the "") and hit Enter. This starts the registry editor.

3: Now press Ctrl+F to search the registry. Search for "jarfile". Usually the first hit will be a folder/key named ".jar" that just references the jarfile. Press F3 to continue the search until the folder name is "jarfile". Usually this is the second hit.

4: Open the subfolders of the jarfile directory until you hit the last one, "command". On the right side you'll see a "Default" key that has a value, referencing a path to your java.exe. Double click that and make sure the entry looks like this:

"C:\Program Files\Java\jre7\bin\java.exe" -jar "%1" %*

Obviously, the path location depends on where you installed Java! However, the symbols after the path are just as important, make sure it looks exactly like that.

If you use "java.exe" as above, you'll always get the command console. If you use "javaw.exe", the console will be hidden unless needed (e.g. for user input) by default. Your choice.

J8c4Xlu.png

Link to comment
Share on other sites

Ok, first of all: do you have java 1.7 installed? Java is used by quite a few applications and it seemed like a reasonable dependency.

As to the command line: I take it you are using windows?

if so, open it my pressing "windows+r" and then type

cmd

(i guess you figured that step out on your own alraedy but for completeness sake..)

In the code block, you'll need to replace "[KSP folder]" with your ksp folder, for example "c:\Program Files\Steam\Steamapss\common\kerbal space program". If that path contains spaces, wrap it in ".

"Cost Balancer" will need to be replaced with the cost balancer folder name inside your game folder.

cd "[KSP FOLDER]"
cd "Cost Balancer"
java -jar "ksp cost balancer.jar"

If that does not work, try

java -version

And post here what it says

As to your other question:

Not at the moment, sorry. I'm pretty swamped with learning for college right now and I'd rather concentrate on the website than on this tool.

That's why I asked about future releases :P when you do have the time, hehe. But yeah, the Java bit may be my problem, I may not have installed it on this machine...

I'll give that a shot and check back with results! Thanks a bunch!

Link to comment
Share on other sites

  • 4 weeks later...
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...