SLTrialCompartment.sleela
lib/advantage/integration/SLTrialCompartment.sleela · 116 line(s) · sleela
<< lib/advantage/integration/SLTrialCompartment.sleela
SLeeLa Standard Library Definition.
Definition: Trial compartment -- a study/experiment compartment for the
vertical-integration subject. >>
#sleela 3.0
material;
artifact;
pure;
gasoline;
< A trial compartment is where you STUDY before committing: it records trial >
< outcomes (integer scores), reports how many passed a threshold, and gives a >
< simple success rate. It de-risks the chain -- a cheap place to learn. Wraps a >
< SLCompartment for its (small) capacitive space; each stored unit is one >
< recorded trial. >
class SLTrialCompartment {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 10543;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-11-08";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-11-08";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 8;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
SLCompartment space;
int[] outcomes;
int count;
int cap;
void configure(String lbl, SLIntegrationKind cat, int maxTrials) {
space = new SLCompartment();
space.configure(lbl, 3, cat);
cap = maxTrials;
if (cap < 1) { cap = 1; }
outcomes = new int[cap];
count = 0;
}
SLCompartment getSpace() { return space; }
int getCount() { return count; }
< Record a trial outcome score. Returns true if recorded (space remained). >
< (Named logTrial, not record: `record` is a reserved SLeeLa keyword.) >
boolean logTrial(int score) {
if (count >= cap) { return false; }
space.store(1);
outcomes[count] = score;
count = count + 1;
return true;
}
< How many recorded trials met or exceeded a pass threshold. >
int passing(int threshold) {
int n = 0;
int i = 0;
while (i < count) {
if (outcomes[i] >= threshold) { n = n + 1; }
i = i + 1;
}
return n;
}
< Success rate as a percentage 0..100 at a threshold (0 if no trials). >
int successRate(int threshold) {
if (count == 0) { return 0; }
return passing(threshold) * 100 / count;
}
< Mean outcome score (integer division; 0 if no trials). >
int meanScore() {
if (count == 0) { return 0; }
int sum = 0;
int i = 0;
while (i < count) { sum = sum + outcomes[i]; i = i + 1; }
return sum / count;
}
String describe() {
return "trial '" + space.getLabel() + "' trials=" + count
+ " mean=" + meanScore();
}
}