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

93
LINES

< > BotCompany Repo | #1002408 // Turing Test Bot

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2245L/15K/49K).

!759

static new L<S> turingTests;

p {
  load("turingTests");
}

synchronized answer {
  if "turing score" ret getTuringScore();
  if "turing tests" ret structure(turingTests);
  if "tests running" ret structure(testsRunning); // TODO: solve the sync problem
  try answer manageSnippetList(s, "turing test", "turingTests");
  
  if "run turing test *" {
    S id = m.fsi(0);
    if (!turingTests.contains(id))
      ret "Not a turing test: " + id;
    runTestAsync(id);
    S url = mainURL() + "1002408?id=" + parseSnippetID(id);
    ret "Test " + shortSnippetLink(id) + " running. Check result here: " + url;
  }
}

static S html(S subUri, Map<S, S> params) {
  L<S> keepFields = litlist();
  S protocolID = params.get("id");
  
  S html = htag("p", "Eleutheria's current Turing score: " + htag("b", getTuringScore()));
  
  html += htag("p", "Tests running: " + structure(testsRunning));
  
  if (isSnippetID(protocolID)) {
    S protocol = loadTextFile(getProgramFile(protocolID, "protocol-" + urlencode(getTuringScore_eleuURL)));

    html += tag("h3", "Protocol of " + quote(getSnippetTitle(protocolID)) + " (" + formatSnippetID(protocolID) + ")") +
      sourceCodeToHTML(protocol);
  }
  
  html += tag("h3", "Tests");
  html += "<ul>";
  for (S id : turingTests)
    html += tag("li", 
      tag("a", formatSnippetID(id) + " - " + getSnippetTitle(id), "href", selfLink(params, keepFields, "id", "" + parseSnippetID(id))) + " " +
      tag("a", "[source]", "href", "http://tinybrain.de/" + parseSnippetID(id)));
  html += "</ul>";
  
  ret html;
}

static S snippetLink(S id) {
  ret tag("a", formatSnippetID(id) + " - " + getSnippetTitle(id), "href", "http://tinybrain.de/" + parseSnippetID(id));
}

static S getTuringScore_eleuURL = "http://bots.tinybrain.de/1002076/raw";

static S getTuringScore() {
  long s = 0, n = 0;
  int tests = 0;
  for (S testID : turingTests) pcall {
    PersistentMap<S, O> scores = new PersistentMap(testID, "turing-scores.map");
    O score = scores.get(getTuringScore_eleuURL);
    if (score == null) continue;
    s += (long) get(score, "score");
    n += (long) get(score, "n");
    ++tests;
  }
  S result = s + " of " + n + " points (" + n(tests, "test");
  int notRun = l(turingTests)-tests;
  if (notRun > 0)
    result += ", " + notRun + " not run yet";
  ret result + ")";
}

static L<S> testsRunning = synchroList();

static void runTestAsync(final S testID) {
  Runnable code = runnable {
    testsRunning.add(testID);
    try {
      Class test = main.hotwire(testID);
      setOpt(test, "mainBot", getMainBot()); // let test know that we are in Eleu process (allows for faster testing)
      callMain(test);
    } finally {
      testsRunning.remove(testID);
    }
  };
  O processManager = getBot("#1002558");
  if (processManager == null)
    new Thread(code).start();
  else
    call(processManager, "start", "Turing Test " + testID, code);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, nysugtttblhj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002408
Snippet name: Turing Test Bot
Eternal ID of this version: #1002408/1
Text MD5: 8ff7d3f3e1700378b6034d83d6c7450a
Transpilation MD5: 6706c45083d63e4dda9c3fcd5e1ddc6c
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-07 20:55:38
Source code size: 2991 bytes / 93 lines
Pitched / IR pitched: No / No
Views / Downloads: 945 / 2855
Referenced in: #1002213 - Eleutheria Homepage (with template & talk to bot)
#1002407 - OLD getTuringScore - retrieve Eleu's current "Turing score"
#3000169 - Answer for stefanreich
#3000174 - Answer for stefanreich
#3000175 - Answer for stefanreich
#3000176 - Answer for stefanreich
#3000177 - Answer for stefanreich
#3000179 - Answer for stefanreich
#3000180 - Answer for stefanreich
#3000181 - Answer for stefanreich
#3000182 - Answer for stefanreich
#3000184 - Answer for stefanreich
#3000185 - Answer for stefanreich
#3000190 - Answer for stefanreich(>> t 20 questions)
#3000195 - Answer for stefanreich (>> y)
#3000196 - Answer for stefanreich (>> y)
#3000197 - Answer for stefanreich (>> program data sizes)
#3000198 - Answer for stefanreich (>> program data sizes)
#3000199 - Answer for stefanreich (>> program data sizes)
#3000200 - Answer for stefanreich (>> program data sizes)
#3000201 - Answer for stefanreich (>> list all files)
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000203 - Answer for stefanreich (>> timing hello bot)
#3000208 - Answer for bgrgndz (>> list sub bots)
#3000209 - Answer for bgrgndz (>> list sub bots)
#3000238 - Answer for stefanreich (>> t power bot)
#3000369 - Answer for Stefan (>> list sub bots)
#3000376 - Answer for stefanreich (>> list sub bots)
#3000377 - Answer for stefanreich (>> timing eleu?)
#3000380 - Answer for stefanreich (>> list sub bots)
#3000381 - Answer for speedforce (>> list sub bots)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)