Skip to content

Instantly share code, notes, and snippets.

@mcnemesis
Created March 2, 2025 17:23

Revisions

  1. mcnemesis created this gist Mar 2, 2025.
    121 changes: 121 additions & 0 deletions zha.tea
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,121 @@
    #!/usr/bin/tttt -fc
    #----------------------------------------------|
    # ZHA: Zee Hacker Assistant (v.1.0.0) | MAR,'25
    #----------------------------------------------|
    # based off of TEAPAT: TEA Personal AssistanT:
    # ref: https://doi.org/10.20944/preprints202502.1849.v1
    #----------------------------------------------|
    # This little program is a mini
    # quasi-general artificial intelligence (qAGI)
    # a special personal assistant perhaps
    # best left for hackers, created
    # using the TEA programming language: https://bit.ly/projtea
    ###############################################|
    # set entity name
    v:vPANAME:{ZHA}
    f:^$:lSET:lNOSET
    l:lSET
    i:{Who do u wish to talk to? }|i: # user's entity name
    g:|f!:^$:lSETI:lRULES|l:lSETI|v:vPANAME|j:lRULES
    l:lNOSET | y*: | v:vPANAME # evoke invoker's entity
    l:lRULES # show instructions
    i!:{At any time, reply with 'end' to quit}|i:
    v:vPROMPT:{: Talk to Me: }
    g*:{ }:vPANAME:vPROMPT | v:vPAPROMPT
    l:lPROMPT # prompt, get answer, process
    # generate question
    n:10000000|s:|v:qN|
    # decide between ANE and NE
    n:|f!:[2357]:qANE:qNE
    l:qANE|
    # decide between AE and ANE
    n:1|f:0:qAE
    # generate ANE
    p!:27
    |s:_:13:5
    |d:_.*$
    |s:
    |v:qR
    |g*:{}:qR:qN
    |j:qF|
    l:qAE # pure AE
    p!:27
    |s:_:13:5
    |d:_.*$
    |s:
    |j:qF|
    l:qNE # pure NE
    |y:qN
    |l:qF # process and package question
    |a:
    |x:{: }
    v:vQ
    # decide on whether question or not
    n:|f:[2357]:lNoQ
    y:vQ
    |x!:{?: }
    j:lProQ
    l:lNoQ
    y:vQ
    |x!:{ : }
    l:lProQ
    # stash generated question
    v:vGenQuestion
    # decide between default or generated prompt
    n:|f:[2468]:lGenPROMPT:lDefPROMPT
    l:lGenPROMPT
    g*:{ }:vPANAME:vGenQuestion | v:vGenPROMPT
    y:vGenPROMPT|j:lDisplayPROMPT
    l:lDefPROMPT
    y:vPAPROMPT
    l:lDisplayPROMPT
    | i: |z:| q:^end$
    # generate answer
    n:10000000|s:|v:N|
    # decide between ANE and NE
    n:|f!:[2357]:ANE:NE
    l:ANE|
    # decide between AE and ANE
    n:1|f:0:AE
    # generate ANE
    p!:27
    |s:_:13:5
    |d:_.*$
    |s:
    |v:R
    |g*:{}:R:N
    |j:F|
    l:AE # pure AE
    p!:27
    |s:_:13:5
    |d:_.*$
    |s:
    |j:F|
    l:NE # pure NE
    |y:N
    |l:F # process and package answer
    |a:|v:vA
    # decide on whether question or not
    n:|f!:[2357]:lQA
    y:vA
    |x!:{? }
    j:lNoQA
    l:lQA
    y:vA
    |x!:{ | }
    l:lNoQA
    # display answer
    |i:
    | j:lPROMPT # and loop