Jump to content

Editing the traits/abilities (pilot/scientist/engineer) of the Kerbals


Recommended Posts

I don't think it is random since there are three constants that appear in every game and they are always the same profession.

It's not strictly speaking random; you name a kerbal the same thing, it will have the same class. The names are somewhat random though. As for Jeb, Bill and Bob, those guys are probably hard-coded because they're the guys you start with.... and because they're Jeb, Bill and Bob :P

Link to comment
Share on other sites

So in an attempt at science I hired a bunch of kerbals and gave them simple names like "a" "A" "1" etc. I found no discernible patterns except that case matters. Some consecutive letters and numbers have the same profession (a-c are all engineers, P-R are all scientists, as are 1-4). Sometimes adding a second/third letter or number makes a change, other times it does not (which I was expecting, but I had hoped the same letter would effect the same change and that is not what I experienced).

In short, whatever Squad programed here is more complex than A=1, B=2, etc. with scientist = ("name" modulo 3)=3 and pilot = ("name" modulo 3)=1.

Link to comment
Share on other sites

So in an attempt at science I hired a bunch of kerbals and gave them simple names like "a" "A" "1" etc. I found no discernible patterns except that case matters.

I would recommend you read up on hash functions. The whole idea usually is to give a seemingly arbitrary result for a given input, because for most applications that gives the best results.

Link to comment
Share on other sites

I understand there is a better than good chance that whatever function Squad is doing will be beyond my bility to figure out. If it's more advanced than back-of-the-envelope math then I'm gonna fail; if it's a full on 32 bit hash (which is so simple for a computer it actually can be faster than 8 bit to process), I'm out of my league. I get that, but I like to poke things (not jelly fish, that's just sad, but maybe a gentle poke to a sea anemone) and try to figure them out.

So 2 more pokes:

1. "Kerman" matters, so whatever it is isn't too customized to KSP since everyone is a Kerman and they could have ignored it but don't.

2. Repetition and order matter ("aaaaa" is different from "aaaaaa" and "aabaaaaa" is different from "abaaaaaa" and "aaaabaaa")

So we know it isn't simple addition/multiplication where order is arbitrary, nor is it based on a single character in the name (3rd letter from the front or whatever). It isn't simply the remainder after division (otherwise consecutive numbers would cycle), and if it is a made-to-order hash table they didn't choose to ignore "Kerman" in it.

Link to comment
Share on other sites

It seems like a sensible thing to do then, at least untill the hash function is discovered or revealedor a better system for storing Kerbal information is implemented, is to collect the generated names of Kerbals in each class so that a into a rainbow table, so that a player who wants to edit his Kerbals to give them specific jobs has a list of authentic (or at least, Known-working) names to choose from.

And perhaps, either have a thread, or a page in the wiki, to collect them. In my current game, at least... (Hopefully, I spelled all the names correctly...)

Pilots: (Jebediah Kerman)

Adlas Kerman

Adsted Kerman

Bargel Kerman

Batrigh Kerman

Billy-Bobmund Kerman

Edlu Kerman

Erzer Kerman

Munbo Kerman

Scientists: (Bob Kerman)

Angan Kerman

Dilfel Kerman

Fertop Kerman

Geofdin Kerman

Gregdred Kerman

Halner Kerman

Hudble Kerman

Joesen Kerman

Jerlan Kerman

Lodrick Kerman

Macvis Kerman

Patbald Kerman

Engineers: (Bill Kerman)

Gusdas Kerman

Herfrey Kerman

Hudming Kerman

Joeke Kerman

Jonbrett Kerman

Jonvan Kerman

Obdrin Kerman

Sondrin Kerman

Link to comment
Share on other sites

So we know it isn't simple addition/multiplication where order is arbitrary, nor is it based on a single character in the name (3rd letter from the front or whatever). It isn't simply the remainder after division (otherwise consecutive numbers would cycle), and if it is a made-to-order hash table they didn't choose to ignore "Kerman" in it.

My guess is it's "name.GetHashCode() % 3" with some class assignment for 0, 1 and 2. That's usually how you implement something like this based on hash functions. The GetHashCode() function is C#'s standard hash function, which is "implementation defined" but returns an int based on the input. For strings (e.g. names) that's usually written in a way that makes the hash code change by a large value for a very small change in the input string (changing one letter, adding a letter, etc). This page has several examples of string hash functions written in C.

If that is how it's done, it'll be pointless building a list of names with their class assignments - it will probably be different on each platform, possibly including different versions of .NET on windows.

Edited by armagheddonsgw
Link to comment
Share on other sites

  • 1 month later...
My guess is it's "name.GetHashCode() % 3" with some class assignment for 0, 1 and 2. That's usually how you implement something like this based on hash functions. The GetHashCode() function is C#'s standard hash function, which is "implementation defined" but returns an int based on the input. For strings (e.g. names) that's usually written in a way that makes the hash code change by a large value for a very small change in the input string (changing one letter, adding a letter, etc). This page has several examples of string hash functions written in C.

If that is how it's done, it'll be pointless building a list of names with their class assignments - it will probably be different on each platform, possibly including different versions of .NET on windows.

I'm actively testing Kerbal renaming. I first generate kerbals using CrewGenerator, iterating new ProtoCrewMembers until I have the desired ExperienceTrait.Title, and then attempt to change the kerbal name in a way that allows the user to get their desired name and retain the profession. Based on what testing I've accomplished along with a trick from 5thHorsman, we have determined that adding a sequence of ascii code 1s to the name can alter the profession while keeping the name.

So far testing has shown that this can be done in the save file, and it works. I've also accomplished it in code and persisted to the save. Also seems to work. In display, the non printing ascii chars are not shown and do not seem to interfere with gameplay, so it gives the illusion of the name you desire.

The trick for me now is to try to persist the kerbal and retrieve the results from ExperienceTrait while editing the kerbal and not requiring exiting the current game. It appears that the traitName is determine upon load of the save game file (OnGameStateLoad).

The hash changes on each load, so I'm not sure that is the method used. may be some hash of the name, but I haven't determined a pattern or factor yet.

I could use assistance in persisting the game save programmatically. I may be able to put something together in SM. As it is now, I have to exit the game and reload so the save file processor assigns the actual profession based on the changes made to the name. It's a brute force approach, but it can be made to be workable.

SM (Ship Manifest) will be released soon with Kerbal renaming features. You may have to save the game a few times, but you will at least be able to get your desired name AND your desired profession.

Update: I have solved the issue with persistence. I can now elegantly manage both the name and profession.

Using KerbalRoster.SetExperienceTrait(ProtoCrewMember) (Thanks badpandabear!), I can now recompute the trait on the fly, to verify my renaming scheme is correct. I then iterate it, adding ascii 1s to the kerbal name until the profession is correct.

The next version of SM will offer Kerbal Renaming and Profession changing, in an elegant solution. I've pushed the changes to my GitHub repository for those that may be interested. Check out the WindowRoster class and the KerbalModel Class for details on implementation.

Edited by Papa_Joe
Link to comment
Share on other sites

Awesome, thanks!

My pleasure! New release is out Ship Manifest 0.90.0_4.1.0. Kerbal renaming and profession management is turned off by default, so be sure to go to settings to enable it. :D

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