This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

what's wrong with this tcl script ?

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
3
3rdBAR
Voice
Posts: 15
Joined: Mon May 15, 2006 6:39 am

what's wrong with this tcl script ?

Post by 3rdBAR »

Below is the accompanying tcl script that's packaged with the MegaHal v3.5 module. I've attempted to use it after installing the module on eggdrop v1.6.19 but none of the commands defined in the script seems to work.

the script:

Code: Select all

# This is an accompanying TCL script to go with the MegaHAL eggdrop module
# It is optional but strongly recommended


# Should the bot learn what is said to it or only converse? Set to on/off.
set learnmode on

# What is the max size the brain should grow to?
# Set to the max number of nodes not ram
set maxsize 100000

# Flood protection: how many max lines per how many seconds should it respond to?
set floodmega 10:60

# Which channels NOT to respond in when the botnick is mentioned (use space delimited list)
# Note: this includes the 'botnick: ' learning trigger
set respondexcludechans ""

# Which keywords besides the botnick should be responded to (use space delimited list)
# Examples can include alternative bot nicknames, people's names, special words like hello, music, etc
set responsekeywords ""

# How often should it talk in response to anything that is said in the channels?
# Set to # of lines or to 0 to turn this off.
set talkfreq 40

# Which channels NOT to talk in in response to all chatter (use space delimited list)
set talkexcludechans ""

# How often should it learn phrases that are said in the channels?
# Set to # of lines or to 0 to turn this off.
set learnfreq 100


# The following settings change the 'psychotic' level or personality of the AI slightly

# Max context size
# Valid values are 1-5
# 2 is highly recommended, 3 is much more boring but it will also produce much more coherent sentences
# 1 will make it babble incoherently a lot of the time and 4-5 will turn it into a parrot instead of a fun AI
set maxcontext 2

# Surprise mode on or off (0/1)
# This changes the way it constructs sentences. 
# If on, it tries to find unconventional combinations of words which means much more fun but also more incoherent sentences
# If off, sentences are safer but more parrot-like so this is only recommended if the brain size is huge )in which case the bot has many safe options to use).
set surprise 1

# Max reply words
# This can help avoid long incoherent sentences that seem to run forever without making sense
# It limits the AI to create shorter sentences
# Recommended setting is about 25-40, set to 0 to allow unlimited size
set maxreplywords 30


#####################################################################


set learningmode $learnmode

# bind the botnick
catch "unbind pub - hal: *pub:hal:"
bind pub - ${nick}: *pub:hal:
catch "unbind dcc - hal *dcc:hal"
bind dcc - $nick *dcc:hal
set megabotnick $nick

# Save and trim the brain once every hour
bind time - "35 * * * *" auto_brainsave
proc auto_brainsave {min b c d e} { 
  global maxsize
  trimbrain $maxsize
  savebrain
}

bind pub m ".savebrain" pub_savebrain
proc pub_savebrain {nick uhost hand chan arg} {
 savebrain
 puthelp "PRIVMSG $chan :Brain saved"
}
bind pub n ".trimbrain" pub_trimbrain
proc pub_trimbrain {nick uhost hand chan arg} {
 global maxsize
 set arg1 [lindex $arg 0]
 if {$arg1 == "" || ![isnum $arg1]} {
	set arg1 $maxsize
 }
 trimbrain $arg1
 puthelp "PRIVMSG $chan :Brain trimmed"
}

bind pub n ".lobotomy" pub_lobotomy
proc pub_lobotomy {nick uhost hand chan arg} {
 savebrain
 file delete megahal.old
 file copy megahal.brn megahal.old
 file delete megahal.brn
 reloadbrain
 savebrain
 puthelp "PRIVMSG $chan :Lobotomy completed! Creating a new brain..." 
}

bind pub - ".braininfo" pub_braininfo
proc pub_braininfo {nick uhost hand chan arg} {
  global learnmode
  set for [treesize -1 0]
  set back [treesize -1 1]
  puthelp "PRIVMSG $chan :My current vocabulary consists of [lindex $for 0] words, my brain size is [expr [lindex $for 1]+[lindex $back 1]] nodes, and learning mode is $learnmode" 
#  if {[file exists megahal.old]} {
#    puthelp "PRIVMSG $chan :This brain has been growing for [duration [expr [unixtime] - [file mtime megahal.old]]]" 
#  }
}

bind pub n ".learningmode" pub_learningmode
proc pub_learningmode {nick uhost hand chan arg} {
  global learnmode
  set arg1 [lindex $arg 0]
  if {$arg1 == "" || ($arg1 != "on" && $arg1 != "off")} {
   puthelp "PRIVMSG $chan :Usage: .learningmode on/off"
   return
  }
  set learnmode $arg1
  learningmode $learnmode
  puthelp "PRIVMSG $chan :Learning mode is now set to $arg1" 
}

bind pub m ".talkfrequency" pub_talkfrequency
proc pub_talkfrequency {nick uhost hand chan arg} {
  global talkfreq
  set arg1 [lindex $arg 0]
  if {$arg1 == ""} {
   puthelp "PRIVMSG $chan :Talking frequency is set to $talkfreq lines" 
   return
  }
  set talkfreq $arg1
  puthelp "PRIVMSG $chan :Talking frequency is now set to $arg1 lines" 
}

bind pub n ".restorebrain" pub_restorebrain
proc pub_restorebrain {nick uhost hand chan arg} {
  if {[file exists megahal.old]} {
    file delete megahal.brn
    file copy megahal.old megahal.brn
    reloadbrain
    puthelp "PRIVMSG $chan :Old brain restored!"
  } else {
    puthelp "PRIVMSG $chan :Old brain not found!" 
  }
}

proc isnum {num} {
  for {set x 0} {$x < [string length $num]} {incr x} {
  if {[string trim [string index $num $x] 0123456789.] != ""} {return 0}
  }
 return 1
}
the accompanying commands documentation:

Code: Select all

COMMANDS

Note that many of the following commands are added by the optional megahal.tcl script.
Feel free to bind more commands to DCC or public as necessary using the provided
TCL commands.


PUBLIC (in channels)
Any line with the botnick in it will get the bot to respond.
To teach it something use - <botnick>: bla bla
.braininfo - displays current brain information such as size, etc.
.megaver - displays version information

Bot masters only:
.forget <text> - this will try to forget the specified text by finding an
                 original phrase that matches the text as closely as possible.
.forgetword <word> - this will forget all phrases containing that word
.savebrain - saves the brain, dictionary and phrase files. Note that the brain
             is automatically saved once every hour and when the bot goes down.
.talkfrequency <#oflines> - sets how often the bot should respond to chatter in
                            public channels.

Bot owners only:
.trimbrain <#ofnodes> - trims the brain down to roughly the specified size.
.lobotomy - backups the current brain, deletes it and starts a new one.
.restorebrain - looks for megahal.old and restores it, deleting the current one.
.learningmode <on/off> - sets whether the bot should learn from <botnick>: etc
                         or only converse.


DCC
To teach it something (and to get a response) use - .<botnick> bla bla
.megaver - displays version information

Bot masters only:
.forget <text> - this will try to forget the specified text by finding an
                 original phrase that matches the text as closely as possible.


TCL
savebrain - duh
reloadbrain - take a guess
trimbrain <#ofnodes> - same as the public command
learningmode <on/off> - ditto
talkfrequency <#oflines> - ditto
setmegabotnick <botnick> - this sets the botnick to look out for in all public
                           chatter. The botnick bindings still have to be
                           changed separately though (see megahal.tcl).
setmaxcontext <size> - use this to change the context size of a brain
                       dynamically. Valid values are 1-5. 2 is highly
                       recommended, 3 is much more boring but it will also
                       produce much more coherent sentences. 1 will make it
                       babble incoherently a lot of the time and 4-5 will turn
                       it into a parrot instead of a fun AI.
reloadphrases - this will reload the brain from scratch but by relearning all
                the phrases in the megahal.phr file only. You can edit the phr
                file or restore an old one this way and weed out the brain.
learnfile <filename> - this will learn all the phrases it finds in the specified
                       file and add them to the current brain.


The following are only useful for people interested in sticking their fingers
into the brain. They are hacks, not user friendly services!

treesize <subbranch> <forwards/backwards> - displays four numbers that give info
                                            on the specified branch:
                                            1. # of branches
                                            2. # of all subbranches/nodes
                                            3. the count counter
                                            4. the usage counter

viewbranch <subbranch> <forwards/backwards> - shows the actual words contained
                                              in a branch and all its subranches
                                              together with the usage counter
                                              for each word.

 <subbranch> - set this to -1 for the main branch, any other number for a
               specified subbranch (it can only go one level down)
 <forwards/backwards> - 0 for the forward tree, 1 for backward tree


TCL VARIABLES
talkfreq - int - see talkfrequency command
learnfreq - int - how often to learn phrases said in the channels
maxsize - int - max brain size. see trimbrain command
maxreplywords - int - max size for replies. This can help keep those endless
                incoherent sentences under control
surprise - int - 0 for off, 1 for on. If on, the AI tries to generate more
           surprising replies.
talkexcludechans - string - space delimited list of chans to exclude from the
                   public chatter (talkfrequency).
respondexcludechans - string - space delimited list of chans to exclude from
                      the bot responses (all lines with the botnick in them)
responsekeywords - string - space delimited list of keywords besides the botnick to respond to
floodmega - couplet - flood settings (how many lines in how many seconds)
The out-of-package file had two apparent spacing typos and one apparent omission of set, which had to be corrected before the script would even load:

was setmaxcontext 2 instead of set maxcontext 2

was setmegabotnick $nick instead of set megabotnick $nick

and

was learningmode $learnmode instead of set learningmode $learnmode

Any observations or opinions will be much appreciated.

TIA
M
Michiellll
Voice
Posts: 3
Joined: Fri Jul 29, 2011 6:13 am

Post by Michiellll »

I installed this version of megahal recently, but I don't understand how to apply this learnfile option.

Does anyone and would you tell me please? It's kind of annoying
Thanks in advance ^^

http://thelastexit.net/megahal/readme.txt

Code: Select all

TCL
savebrain - duh
reloadbrain - take a guess
trimbrain <#ofnodes> - same as the public command
learningmode <on/off> - ditto
talkfrequency <#oflines> - ditto
setmegabotnick <botnick> - this sets the botnick to look out for in all public
                           chatter. The botnick bindings still have to be
                           changed separately though (see megahal.tcl).
setmaxcontext <size> - use this to change the context size of a brain
                       dynamically. Valid values are 1-5. 2 is highly
                       recommended, 3 is much more boring but it will also
                       produce much more coherent sentences. 1 will make it
                       babble incoherently a lot of the time and 4-5 will turn
                       it into a parrot instead of a fun AI.
reloadphrases - this will reload the brain from scratch but by relearning all
                the phrases in the megahal.phr file only. You can edit the phr
                file or restore an old one this way and weed out the brain.
learnfile <filename> - this will learn all the phrases it finds in the specified
                       file and add them to the current brain.
Post Reply