!759 snew JTextArea thoughtArea; snew JTextArea chatArea; snew JTextField chatField; static new L script; static int idx; p { script = parsePoem("#1003305"); showSideBySide("GMail Bot", withTitle("Chat", centerAndSouth(chatArea, chatField)), withTitle("Thoughts", thoughtArea)); chatField.requestFocus(); onEnter(chatField, runnable { pcall { if (eq(nextMove(), "move")) ++idx; } chatArea.append(chatField.getText() + "\n"); chatField.selectAll(); }); swingEverySecond(thoughtArea, runnable { predict(); }); } svoid predict { new StringBuilder buf; try { buf.append(unparsePoem(subList(script, idx)) + "\n\n"); S move = nextMove(); buf.append("Probable next move: " + move + "\n\n"); } catch e { buf.append("\n\n" + getStackTrace(e)); } setText(thoughtArea, buf); } sS nextMove { S input = chatField.getText(); if (idx >= l(script)) ret "stop"; E e = get(script, idx); if (e.q != null && match(e.q, input)) ret "move"; ret "stop"; }