Home /Modules/gameplay/InferenceEngine.sleela

InferenceEngine.sleela

lib/gameplay/InferenceEngine.sleela · 119 line(s) · sleela

<< lib/gameplay/InferenceEngine.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines InferenceEngine, the in-game modeler that projects a
     Player's Expected Future and, when the player instead gets the Boss's help,
     assembles a DetailedReport with some Game-Engineering moves already decided.
     This is the brain behind move (b), "ask for help or new routes".
   
   InferenceEngine is a NATURAL / LOADABLE MODULE sharing the common module
   contract (load / loaded / moduleName / describe). It is deterministic: given
   the same player state and turn, it projects the same future and decides the
   same moves, so a replayed game infers identically. It names, but does not
   depend on, the lib/inference-model package family.
   
   Family: gameplay. >>
#sleela 2.5
material;
< Unified SLeeLa SDK front-end object. >
class InferenceEngine {
  < ---- 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 = 10323;
  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 = "InferenceEngine";

  int loadedFlag;
  < the custom game's intended finishing turn >
  int targetTurn;

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

  void setTarget(int turn) { if (turn > 0) { targetTurn = turn; } }

  < Project the Player's Expected Future at `now`. Pace is driven by the >
  < player's experience: more experience finishes sooner. Confidence rises with >
  < the player's Person/Citizen quality — a clearer person is easier to model. >
  ExpectedFuture model(Player p, int now) {
    ExpectedFuture ef = new ExpectedFuture();
    ef.load();
    if (p == null) { return ef; }
    < Pace: a baseline span, shortened by experience (capped so it stays sane). >
    int span = 24 - (p.xp() / 10);
    if (span < 4) { span = 4; }
    int projectedEnd = now + span;
    < 40..90 >
    int confidence = 40 + (p.qualityScore() / 2);
    ef.project(now, projectedEnd, targetTurn, confidence);
    return ef;
  }

  < Assemble the Boss's DetailedReport: concrete Game-Engineering moves already >
  < chosen for the player, priced by the player's own quality. The player pays >
  < (or cannot), and that is recorded on the report. >
  DetailedReport brief(Player p, int baseCostCents) {
    DetailedReport rep = new DetailedReport();
    rep.load();
    rep.name("Game-Engineering Brief");
    < The pre-decided moves. These are the boss doing the thinking for you. >
    rep.decide("Re-route the critical path through the cheaper supplier.");
    rep.decide("Bank two rolls now; spend them on the schedule crunch later.");
    rep.decide("Trade one unit of tact for the stakeholder's early sign-off.");
    rep.decide("Lock the medium portfolio bet before the window closes.");
    if (p == null) {
      rep.setPrice(baseCostCents, false);
      return rep;
    }
    int price = p.infoPriceCents(baseCostCents);
    boolean paid = p.payForInfo(baseCostCents);
    rep.setPrice(price, paid);
    return rep;
  }

  int target() { return targetTurn; }

  String describe() {
    return MODULE + " targetTurn=" + targetTurn;
  }
}