Jump to content

Mod to Generate Science Contracts by Searching Science Archives to Find New Science to Do


arkie87

What should the name of this mod be?  

34 members have voted

  1. 1. What should the name of this mod be?

    • Contract Configurator Pack: Field Research
      16
    • Contract Configurator Pack: Undiscovered Science
      12
    • Contract Configurator Pack: Science Explorer
      2
    • It's own mod: Do Science!
      4


Recommended Posts

I was wondering how difficult it would be to write a mod that searches through the science archives to find an experiment/biome pair that you havent yet conducted, and then tells you to go there and do that experiment. The contract would pay you decently, but not give you any science on it's own (and maybe a little rep too).

The advantages of this is that you dont have to keep track of what experiments you've done where, and it would also help tie the game together.

What do you guys think? Is it a good idea? Any constructive criticism? How difficult would it be to write and/or do you want to write it?

Edited by arkie87
Link to comment
Share on other sites

Interesting.

It shouldn't be too hard, though probably more difficult than it seems if it is anything like my projects.

I think most of what you need is available in the randd and sciencesubject classes. You could also take a look a bit at my forscience code, because I do quite a bit of checking for experiments which may give you some inspiration.

If you are just getting started with modding, a limited scope like this would be a great way to start.

Link to comment
Share on other sites

Interesting.

It shouldn't be too hard, though probably more difficult than it seems if it is anything like my projects.

I think most of what you need is available in the randd and sciencesubject classes. You could also take a look a bit at my forscience code, because I do quite a bit of checking for experiments which may give you some inspiration.

If you are just getting started with modding, a limited scope like this would be a great way to start.

Thanks a lot for the tips and encouragement.

Yes, I am completely new to modding, but low-moderate experience programming in real languages (since Matlab doesnt count).

- - - Updated - - -

You mean something like [x] Science! ? Except that it generates contracts instead of listing stuff you haven't done?

Basically, yeah. Maybe i could even use [x] Science's source... or perhaps, i could ask the maker of x-science if he is interested in making my mod?

Link to comment
Share on other sites

Interesting. I think this could be tied to Contact Configurator.

Sounds like a good combination to me - it'd be nice to see contracts for places I haven't tried out my instruments yet, rather than rinse + repeat on the science in orbit around ... contracts.

... and it means I get money as well as science for doing a contract :D

Link to comment
Share on other sites

Sounds like a good combination to me - it'd be nice to see contracts for places I haven't tried out my instruments yet, rather than rinse + repeat on the science in orbit around ... contracts.

... and it means I get money as well as science for doing a contract :D

Any interest in writing the plugin? :sticktongue:

Link to comment
Share on other sites

I like the idea, and Contract Configurator can get about 90% of the way there as it currently stands. It has everything needed for building up the contract (mainly would be the CollectScience parameter). What's it's missing is stuff for detecting what science needs to be done where, but that's not too difficult, since all the framework pieces are in place, and it's just adding a bunch of new functions, like ones that get all the biomes for a celestial body, getting the list of experiements that can be performed in a given biome, getting the amount of science that can still be gathered for a given combination, etc.

If someone expresses an active interest in doing this with Contract Configurator, let me know and I can provide assistance and start chipping away at some of the required features.

Link to comment
Share on other sites

I like the idea, and Contract Configurator can get about 90% of the way there as it currently stands. It has everything needed for building up the contract (mainly would be the CollectScience parameter). What's it's missing is stuff for detecting what science needs to be done where, but that's not too difficult, since all the framework pieces are in place, and it's just adding a bunch of new functions, like ones that get all the biomes for a celestial body, getting the list of experiements that can be performed in a given biome, getting the amount of science that can still be gathered for a given combination, etc.

If someone expresses an active interest in doing this with Contract Configurator, let me know and I can provide assistance and start chipping away at some of the required features.

I have zero experience with modding and contract configurator. However, the maker of [x]-Science recommneded i look through his code to find similar functions to understand how to search science archives...

Link to Source Code

The code that finds all the science is in RefreshExperimentCache() in ExperimentFilter.cs if you want to have a look.

The code that checks to see if an experiment is completed is in Update() in Experiment.cs

Cheers

Z-Key Aerospace

Link to comment
Share on other sites

KSP modding isn't difficult (assuming you have some C# familiarity), the biggest issue is the lack of Squad-produced documentation.

Anyway, just to give you an idea of how easy this would be with Contract Configurator, here's the full config for getting a landed crew report from any body the player has orbited (as an example). Obviously there's still the missing pieces, but this would be a good start:

CONTRACT_TYPE
{
name = CollectScienceExample

// Contract text
title = CollectScience example
description = A more detailed description of the contract. This is where you come in.
synopsis = We want you to do a thing.
completedMessage = You have done the thing.

maxSimultaneous = 1

targetBody = OrbitedBodies().Random()

// Contract rewards
rewardScience = 100.0
rewardFunds = 100000.0

PARAMETER
{
name = CollectScience
type = CollectScience

situation = SrfLanded

// Valid values for stock KSP are:
// asteroidSample
// crewReport
// evaReport
// mysteryGoo
// surfaceSample
// mobileMaterialsLab
// temperatureScan
// barometerScan
// seismicScan
// gravityScan
// atmosphereAnalysis
experiment = crewReport
}
}

Link to comment
Share on other sites

KSP modding isn't difficult (assuming you have some C# familiarity), the biggest issue is the lack of Squad-produced documentation.

Anyway, just to give you an idea of how easy this would be with Contract Configurator, here's the full config for getting a landed crew report from any body the player has orbited (as an example). Obviously there's still the missing pieces, but this would be a good start:

CONTRACT_TYPE
{
name = CollectScienceExample

// Contract text
title = CollectScience example
description = A more detailed description of the contract. This is where you come in.
synopsis = We want you to do a thing.
completedMessage = You have done the thing.

maxSimultaneous = 1

targetBody = OrbitedBodies().Random()

// Contract rewards
rewardScience = 100.0
rewardFunds = 100000.0

PARAMETER
{
name = CollectScience
type = CollectScience

situation = SrfLanded

// Valid values for stock KSP are:
// asteroidSample
// crewReport
// evaReport
// mysteryGoo
// surfaceSample
// mobileMaterialsLab
// temperatureScan
// barometerScan
// seismicScan
// gravityScan
// atmosphereAnalysis
experiment = crewReport
}
}

Thanks for the code! I have a little experience with C#, but very beginner level.

I can sort of see what your code does, but yeah, it is missing some of the more difficult tasks (as you said).

Did you have a chance to review the source code I linked? Does it do what needs to be done to search which biomes have experimental science available? How easy would it be to integrate some of that source code into your contract configurator to give extra functionality (at least as a starting point for this mod)?

Link to comment
Share on other sites

Yup, that's good stuff - it just would need to be pulled out into the appropriate places for Contract Configurator. I'll take a look at that in the 1.0.4 version (1.0.3 needs to get released today or tomorrow - got some stuff people are waiting on, and need to verify the RemoteTech support work with their new release).

Link to comment
Share on other sites

Yup, that's good stuff - it just would need to be pulled out into the appropriate places for Contract Configurator. I'll take a look at that in the 1.0.4 version (1.0.3 needs to get released today or tomorrow - got some stuff people are waiting on, and need to verify the RemoteTech support work with their new release).

Any progress? Since 1.0.3 hasnt been released, i assume that means you havent had a chance to try to work on this idea?

Link to comment
Share on other sites

1.0.3 and 1.0.4 have been released (1.0.4 was a hot fix for an issue). I've made a teeny bit of progress, and will be working on it again tonight. Thanks for checking in though - it helps to know that you're actually interested (ie. so I know that it's worth doing the work on this stuff).

Anyway, I hadn't reported in since what's been done isn't useful on its own. What I did was added a wrapper class for Biome and added some methods to the celestial body to get all its biomes. Next will be filling out the Biome class and adding stuff for the more sciencey items such as experiments, etc. You can keep an eye on the CHANGES.txt in GitHub for a preview of what's already done for the next release.

I'll give some more details on that Biome class as well as the other stuff once there's a little bit more - probably looking at late tonight or tomorrow night.

Link to comment
Share on other sites

1.0.3 and 1.0.4 have been released (1.0.4 was a hot fix for an issue). I've made a teeny bit of progress, and will be working on it again tonight. Thanks for checking in though - it helps to know that you're actually interested (ie. so I know that it's worth doing the work on this stuff).

Anyway, I hadn't reported in since what's been done isn't useful on its own. What I did was added a wrapper class for Biome and added some methods to the celestial body to get all its biomes. Next will be filling out the Biome class and adding stuff for the more sciencey items such as experiments, etc. You can keep an eye on the CHANGES.txt in GitHub for a preview of what's already done for the next release.

I'll give some more details on that Biome class as well as the other stuff once there's a little bit more - probably looking at late tonight or tomorrow night.

Oh, i checked your mod's page, but confused the KSP version with your mod version :sticktongue: I see now it has been released.

Thanks for working on it!

Do you have a gameplan for what methods/functions are needed for Contract Configurator to be able to make these types of contracts?

Link to comment
Share on other sites

Oh, i checked your mod's page, but confused the KSP version with your mod version :sticktongue: I see now it has been released.

Thanks for working on it!

Do you have a gameplan for what methods/functions are needed for Contract Configurator to be able to make these types of contracts?

Not specifically, will be figuring it out as I go along. Off the top of my head:

  1. Need a method to get the list of valid experiments for a given biome/situation.
  2. Need a method to get the amount of science done/remaining for a given experiment/biome/situation
  3. Probably need a way to easily sum across experiments and/or situations (so you can more easily generate the contract for a biome/situation where there is more than X science available to be done).

Once I have that I'll see how it looks... as I dig into it I may see more that's needed. Or once I toss it over to you, you may start to ask "how do I do X?", which will result in more stuff. Anyway, hopefully all the above is done in 3-4 days maybe?

Link to comment
Share on other sites

Not specifically, will be figuring it out as I go along. Off the top of my head:

  1. Need a method to get the list of valid experiments for a given biome/situation.
  2. Need a method to get the amount of science done/remaining for a given experiment/biome/situation
  3. Probably need a way to easily sum across experiments and/or situations (so you can more easily generate the contract for a biome/situation where there is more than X science available to be done).

Once I have that I'll see how it looks... as I dig into it I may see more that's needed. Or once I toss it over to you, you may start to ask "how do I do X?", which will result in more stuff. Anyway, hopefully all the above is done in 3-4 days maybe?

I was thinking more like:

(1) get list of orbited or explored contracts (probably orbited is better since sometimes i miss being offered explore contracts)

(2) select one randomly (remove it from the list after selecting it)

(3) pick a random number to select either orbit experiment or suface (biome) experiment

(4) if orbit experiment:

(4a) go through list of orbit experiments available. If at least one is available, offer contract (if more than one is available, offer separate money for each). If none are available, go to 4b.

(4b) go through biome list; select a biome randomly (and then remove it from the list). Get list of experiments; if at least one is available, offer a contract (if more than one is available and researched, offer separate money for each experiment). If none are available, select a different biome and repeat. If biome list is empty, then go back to step 2 (selecting a planet).

(5) offer contract

Thanks for your effort, by the way!

EDIT: actually, instead of step 3: randomly picking between orbit and biome, i think its better to first start with orbit, and all of those experiments have been done, THEN select biome. (or for the first version, we can start only with biome/surface experiments)

Edited by arkie87
Link to comment
Share on other sites

That's just not how Contract Configurator works - but there's alternatives for most of what you're after.

(1) get list of orbited or explored contracts (probably orbited is better since sometimes i miss being offered explore contracts)

Pretty much have a look at anything/everything in the REQUIREMENT nodes. A requirement is a pre-requisite for a contract to show up. So if you had a contract for Minmus, you could have "orbited Minmus" as the requirement for the contract to be offered.

(2) select one randomly (remove it from the list after selecting it)

If you're trying to ensure that a contract for the same thing isn't offered multiple times, there's other ways to do this. Setting maxSimultaneous=1 is the simplest.

(3) pick a random number to select either orbit experiment or suface (biome) experiment

Doable. You may be better off having them as separate contract types, then you can further differentiate them (have additional parameters, different contract text, etc.)

(4) if orbit experiment:

(4a) go through list of orbit experiments available. If at least one is available, offer contract (if more than one is available, offer separate money for each). If none are available, go to 4b.

As above, I'd treat these as totally different contract types. Building a list on the fly is somewhat problematic, but doable if you set a max limit (albeit ugly). Check out the gas-giant tourism contract from Tourism Plus as an example of this.

(4b) go through biome list; select a biome randomly (and then remove it from the list). Get list of experiments; if at least one is available, offer a contract (if more than one is available and researched, offer separate money for each experiment). If none are available, select a different biome and repeat. If biome list is empty, then go back to step 2 (selecting a planet).

Basically all possible, but the control flow is different. It would be more like:

  1. Select a CelestialBody with biomes that have science to be done.
    targetBody = LandedBodies().Where(cb => cb.BunchOfStuffThatINeedToComeUpWithToCheckForScience()).Random()


  2. Select a biome from the celestial body that has science to be done.
    biome = @targetBody.AllBiomes().Where(b => b.SomeCheckForScience()).Random()


  3. Build a list of experiments
    experiments = biome.SomeOtherFunctionToGetExperiments().Where(exp => exp.SomeFunctionForCheckingIfScienceAvailable())


  4. Dump the experiments into a bunch of CollectScience parameters (as was done in the gas-giant contract above).

(5) offer contract

Automatic. :)

Thanks for your effort, by the way!

You're welcome! Hopefully once you get the hang of it you'll be willing to continue down this route - it's not as rigid as I'm making it out to be... once you adjust your thinking. :sticktongue:

- - - Updated - - -

EDIT: actually, instead of step 3: randomly picking between orbit and biome, i think its better to first start with orbit, and all of those experiments have been done, THEN select biome. (or for the first version, we can start only with biome/surface experiments)

I'll have to think about that one... can probably come up with something, but it may not be bullet proof.

Link to comment
Share on other sites

Not specifically, will be figuring it out as I go along. Off the top of my head:

  1. Need a method to get the list of valid experiments for a given biome/situation.
  2. Need a method to get the amount of science done/remaining for a given experiment/biome/situation
  3. Probably need a way to easily sum across experiments and/or situations (so you can more easily generate the contract for a biome/situation where there is more than X science available to be done).

RDEnvironmentAdapter and ResearchAndDevelopment have some nice methods (actually I think they might be the same methods, I'm not really sure what the difference is) for getting all of the available experiments, all of the biomes for a given planet (not sure about the KSC biomes), and all of the existing ScienceSubjects (ie the ones that are actually in the science archives).

From there it should be fairly simple to check each experiment, check its valid situation combinations, and check of such a subject exists and/or if it has science remaining.

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...