from cli import *
from cli_test import *
from ctx import *
from ctx_test2 import *
#from ctx_test import *
#from ctx_test_Python import *
from llm_test import *
from llm_test_Python import *
from memory_test import *
import sys

print(ctx_test_Controller_executeFunctions_registerFunction_set())
print(ctx_test_Controller_processQueue())
print(ctx_test_Controller_registerFieldCallback_match())
print(ctx_test_Controller_registerFieldCallback_mismatch())
print(ctx_test_memoryContext_field())
print(ctx_test_memoryContext_setField())

print(llm_test_Python_copyByValue())
print(llm_test_isDigit_digit())
print(llm_test_isDigit_notDigit())
print(llm_test_strToInt())

print(memory_test_detectMismatchedItems())
print(memory_test_detectMismatchedItems_itemTwice())
print(memory_test_detectVictory())
print(memory_test_generateConstPlayfield())
print(memory_test_hideMatchingItems())
print(memory_test_selectItem_1x())
print(memory_test_selectItem_2x())
print(memory_test_selectItem_3x())

print(cli_test_exit_e())
print(cli_test_exit_exit())
print(cli_test_exit_victory())
print(cli_test_exit_q())
print(cli_test_exit_quit())
print(cli_test_goOn())
print(cli_test_greetUser())
print(cli_test_showHelp_h())
print(cli_test_showHelp_help())
print(cli_test_selectItem())
print(cli_test_promptSecondItemSelection())
print(cli_test_reportMatchedItems())
print(cli_test_reportMismatchedItems())
print(cli_test_reportVictory())

ctrl = ctx_Controller(memory_createContext())
ctrl.registerFunctions([
  cli_exit,
  cli_goOn,
  cli_greetUser,
  cli_promptSecondItemSelection,
  cli_reportMatchedItems,
  cli_reportMismatchedItems,
  cli_reportVictory,
  cli_selectItem,
  cli_showHelp,
  memory_detectMismatchedItems,
  memory_detectVictory,
  memory_generateConstPlayfield,
  memory_hideMatchingItems,
  memory_selectItem,
])

def printOutput(c):
  if c.recentField.startswith("output"):
    print(c.field(c.recentField))
ctrl.registerCallback(printOutput)
ctrl.registerFieldCallback("exit", lambda c: sys.exit(0))

ctrl.set("didLaunch", True)
ctrl.set("playfieldSize", 2)

for line in sys.stdin:
  ln = line.rstrip()
  ctrl.set("input", ln)
