Skip to content

Commit

Permalink
Fixed the diminishing science value of transmitted data
Browse files Browse the repository at this point in the history
Breaking Grounds replaced the implementation of ResearchAndDevelopment.GetReferenceDataValue
with a function that no longer returns a constant value for equally sized data chunks. Instead,
the value of subsequent chunks are less than the values of the previous ones. Usually this
doesn't affect the game at all, because science usually is done in one chunk.

They probably did this for their surface experiments, so that they never cease to produce
scientific value, but will continue to give science output forever.

Fixes #421
  • Loading branch information
SirMortimer committed Jun 8, 2019
1 parent 75210fe commit 70cbaa0
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/Kerbalism/Science/Science.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public static class Science
{
// this controls how fast science is credited while it is being transmitted.
// try to be conservative here, because crediting introduces a lag
private const double buffer_science_value = 0.4; // min. 0.01 value
private const double min_buffer_size = 0.01; // min. 10kB
private const double buffer_science_value = 0.3;

// this is for auto-transmit throttling
public const double min_file_size = 0.002;
Expand Down Expand Up @@ -111,18 +110,15 @@ public static void Update(Vessel v, Vessel_info vi, VesselData vd, Vessel_resour
// special case: file size on drive = 0 -> buffer is 0, so no need to do anyhting. just delete.
if (file.buff > double.Epsilon)
{
bool credit = file.size <= double.Epsilon;

// this is the science value remaining for this experiment
var remainingValue = Value(exp_filename, 0);

// this is the science value of this sample
double dataValue = Value(exp_filename, file.buff);
bool doCredit = file.size <= double.Epsilon || dataValue > buffer_science_value;;

if (!credit && file.buff > min_buffer_size) credit = dataValue > buffer_science_value;

// if buffer is full, or file was transmitted completely
if (credit)
// if buffer science value is high enough or file was transmitted completely
if (doCredit)
{
var totalValue = TotalValue(exp_filename);

Expand Down Expand Up @@ -219,7 +215,6 @@ public static float Credit(string subject_id, double size, bool transmitted, Pro
return credits;
}


// return value of some data about a subject, in science credits
public static float Value(string subject_id, double size = 0)
{
Expand All @@ -237,10 +232,7 @@ public static float Value(string subject_id, double size = 0)
var subject = ResearchAndDevelopment.GetSubjectByID(subject_id);
if (subject == null) return 0.0f;

// get science value
// - the stock system 'degrade' science value after each credit, we don't
double R = ResearchAndDevelopment.GetReferenceDataValue((float)size, subject);

double R = size / subject.dataScale * subject.subjectValue;
double S = subject.science;
double C = subject.scienceCap;
double credits = Math.Max(Math.Min(S + Math.Min(R, C), C) - S, 0.0);
Expand Down

0 comments on commit 70cbaa0

Please sign in to comment.