Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

55
LINES

< > BotCompany Repo | #1025733 // Weight Change Bot [original demo, OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 5909K of libraries. Click here for Pure Java version (17181L/95K).

!7

standardBot1 DiscordToPhilosophyBot {
  new SimpleFactStore factStore;
  
  transient S theory = [[
    import math
    
    theory validity {
      // a human weighs between 80 and 400 pounds
      $x is a human
        & $x weighs ($y pounds)
        => $y >= 80 & $y <= 400
        
      contradiction => say (That can't be right)
    }
    
    theory (weight change) {
      $x weighs ($y pounds)
        & last time $x weighed ($z pounds)
        => proc {
          if ($y < $z):
            say (You lost weight)
          else if ($y > $z):
            say (You gained weight)
          else:
            say (You are stagnant)
        }
    }

    theory (remember last weight) {
      $x weighs ($y pounds)
        => proc {
          unless contradiction:
            delete all (last time $x weighed ($z pounds))
            store      (last time $x weighed ($y pounds))
        }
    }
    
    theory (interpret input) {
      $x says (i weigh $y pounds)
        => $x weighs ($y pounds)
      
      $x says (my weight is $y pounds)
        => $x weighs ($y pounds)
    }
  ]];
  
  sync S processSimplifiedLine(S s, O... _) {
    try answer super.processSimplifiedLine(s, _);
    
    try answer factStore_cmds(factStore, s, authed(_));
    ret philosophyBotWithFactStore_discordAnswer(theory, factStore, s, _);
  }
}

Author comment

Began life as a copy of #1025304

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025733
Snippet name: Weight Change Bot [original demo, OK]
Eternal ID of this version: #1025733/28
Text MD5: 9e7b453ea85689ff08071f12b3e5d051
Transpilation MD5: 8fa77040c91f456577893b46c627fd0f
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-18 22:11:52
Source code size: 1395 bytes / 55 lines
Pitched / IR pitched: No / No
Views / Downloads: 240 / 936
Version history: 27 change(s)
Referenced in: [show references]