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

41
LINES

< > BotCompany Repo | #1025605 - Philosophy Bot 2 - match questions and answers [works with a very high chance, but without proper backtracking]

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

Uses 788K of libraries. Click here for Pure Java version (6352L/32K).

!7

cmodule PhilosophyBot2 extends DynPrintLog {
  transient L unmappedLines = ll("good", "early morning");
  transient L unmappedQuestions = ll("what is the time", "how do you feel");
  
  transient S program = [[
    
funnyAlgorithm

    funnyAlgorithm => proc {
      while (there are unmapped questions):
        find (an unmapped question) x
        find (an unmapped line) y
        map x to y
    }

  ]];
  
  transient new PhilosophyBot1 bot;

  start-thread {
    bot.program = program;
    bot.addNativePredicate("there are unmapped questions",
      () -> nempty(unmappedQuestions));
    bot.addNativePredicate("find (an unmapped question) x",
      () -> {
        print("find unmapped question x");
        if (empty(unmappedQuestions)) false;
        ret litcimap(x := random(unmappedQuestions));
      });
    bot.addNativePredicate("find (an unmapped line) z",
      () -> {
        print("find unmapped line z");
        if (empty(unmappedLines)) false;
        ret litcimap(z := random(unmappedLines));
      });

    bot.run();
  }
}

Author comment

Began life as a copy of #1025598

download  show line numbers  debug dex   

Travelled to 2 computer(s): mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1025605
Snippet name: Philosophy Bot 2 - match questions and answers [works with a very high chance, but without proper backtracking]
Eternal ID of this version: #1025605/1
Text MD5: 4cd7d521a2a7e77082597009d4b1045e
Transpilation MD5: 189e238f1028eafe6d42da2217ee8323
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-07 14:23:43
Source code size: 1093 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 10 / 20
Referenced in: [show references]