Home /Modules/gameplay/ExpectedFuture.sleela

ExpectedFuture.sleela

lib/gameplay/ExpectedFuture.sleela · 111 line(s) · sleela

<< lib/gameplay/ExpectedFuture.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines ExpectedFuture, the forward-looking projection the
     Inference Engine shows a Player on a winning "ask for help" roll. It answers
     the one question move (b) exists to answer: am I on schedule in my own
     custom game? It holds a projected turn, a target turn, and the gap between.
   
   ExpectedFuture is a NATURAL / LOADABLE MODULE sharing the common module
   contract (load / loaded / moduleName / describe). It is produced by
   InferenceEngine; a Player reads onSchedule() and the projected end to decide
   whether to push, coast, or panic (professionally).
   
   Family: gameplay. >>
#sleela 2.5
material;
< Unified SLeeLa SDK front-end object. >
class ExpectedFuture {
  < ---- 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 = 10311;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-07";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < 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; }

  static final String MODULE = "ExpectedFuture";

  int loadedFlag;
  < where the player is now >
  int currentTurn;
  < when, at this pace, they finish >
  int projectedEnd;
  < when the custom game says they SHOULD finish >
  int targetTurn;
  < 0..100, how sure the engine is >
  int confidence;

  < --- loadable-module contract ------------------------------------------ >
  void load() {
    loadedFlag = 1;
    currentTurn = 0; projectedEnd = 0; targetTurn = 0; confidence = 0;
  }
  boolean loaded() { return loadedFlag == 1; }
  String moduleName() { return MODULE; }

  void project(int now, int projected, int target, int conf) {
    currentTurn = now;
    projectedEnd = projected;
    targetTurn = target;
    confidence = conf;
    if (confidence < 0) { confidence = 0; }
    if (confidence > 100) { confidence = 100; }
  }

  < Negative = ahead of schedule, 0 = exactly on, positive = behind. >
  int scheduleGap() { return projectedEnd - targetTurn; }

  boolean onSchedule() { return scheduleGap() <= 0; }
  boolean behind() { return scheduleGap() > 0; }

  int turnsRemaining() {
    int r = projectedEnd - currentTurn;
    if (r < 0) { return 0; }
    return r;
  }

  int confidenceScore() { return confidence; }

  String yn(boolean v) { if (v) { return "yes"; } return "no"; }

  String describe() {
    return MODULE + " now=" + currentTurn + " projectedEnd=" + projectedEnd
         + " target=" + targetTurn + " gap=" + scheduleGap()
         + " onSchedule=" + yn(onSchedule()) + " confidence=" + confidence;
  }
}