| View previous topic :: View next topic |
| Author |
Message |
sarius Voice
Joined: 05 Aug 2005 Posts: 20
|
Posted: Mon Nov 28, 2005 10:41 pm Post subject: Boggle Game Script |
|
|
I tried searching in the TCL archive and also google but I can't one specifically written for tcl or eggdrop. Or maybe it has not been made public =P
Anyway, I'm in the midst of writing one for my own educational purpose, interest and for a bunch of friends in my irc channel.
Here's the gist of it
| Code: | set die(0) "lrytte"
set die(1) "vthrwe"
set die(2) "eghwne"
set die(3) "seotis"
set die(4) "anaeeg"
set die(5) "idsytt"
set die(6) "oattow"
set die(7) "mtoicu"
set die(8) "afpkfs"
set die(9) "xlderi"
set die(10) "hcpoas"
set die(11) "ensieu"
set die(12) "yldevr"
set die(13) "znrnhl"
set die(14) "obbaoj"
set die(15) "nmihuq"
proc generateboggle {bog} {
global die
set letters ""
set numbers ""
set randnum ""
while { [llength $letters] < 16 } {
set foundadupe 0
set randnum [rand 16]
set counter 0
while {$counter < [llength $numbers]} {
set dupenumtocheck [lrange $numbers $counter $counter]
if {$dupenumtocheck == $randnum} {
set foundadupe 1
}
incr counter
}
if {$foundadupe == 0} {
lappend numbers $randnum
set randletter [string index $die($randnum) [rand 6]]
lappend letters $randletter
}
}
return $letters
}
proc Boggle {nick uhost hand chan args} {
global bog
set bogstring [generateboggle $bog]
putquick "privmsg #Boggle :[join [split [lrange $bogstring 0 3] " "] " "]"
putquick "privmsg #Boggle :[join [split [lrange $bogstring 4 7] " "] " "]"
putquick "privmsg #Boggle :[join [split [lrange $bogstring 8 11] " "] " "]"
putquick "privmsg #Boggle :[join [split [lrange $bogstring 12 15] " "] " "]"
utimer 360 "EndofRound #Boggle"
} |
This is basically just for generating the a 4x4 Boggle board. The next step (which I have not written) is to feed this board into a Boggle solver written in C.
The boggle solver will generate a list of all the possible words based on a dictionary text file.
The eggdrop will then match the answers typed in by the players against this list.
The Boggle solver was obtained from here
Ideally, I would like to convert the C code into tcl, but my knowledge in C is pretty limited.
Anyway, I would like to know how to use the egg to feed the letters into the Solver. To run the solver, I have to type ./boggle2 and press enter. Then I have to type the letters on the boggle board one by one, pressing enter after each one.
After all the letters have been entered, the solver will print the list of words on the console screen. I need to change it to print to a text file.
I think I should be able to manage the matching of answers to the text file after this. Hopefully!
Any comments/advice/suggestions will be greatly appreciated! |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Nov 29, 2005 1:27 am Post subject: |
|
|
assuming that boggle reads board's data from standard input, you need to open a pipeline and write to it:
| Code: |
set f [open "|boggle >output.txt" w]
foreach {k data} [array get die] {puts $f $data}
close $f
|
_________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
sarius Voice
Joined: 05 Aug 2005 Posts: 20
|
Posted: Tue Nov 29, 2005 8:33 am Post subject: |
|
|
Hi demond. Thanks for such a prompt reply.
It seems to be working without foreach. I just used \n.
Hmm... will update more when I finish the rest of the script  |
|
| Back to top |
|
 |
sarius Voice
Joined: 05 Aug 2005 Posts: 20
|
Posted: Wed Nov 30, 2005 12:46 am Post subject: |
|
|
| The script is more or less done. However I can't release it as a standalone tcl script because it requires the Boggle Solver to work. But I'll be more than happy to share the code if anyone's interested. |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Wed Nov 30, 2005 2:36 am Post subject: |
|
|
you could try to embed boggle's C code into your Tcl script using Critcl, but I'd suggest you learn C and port boggle to Tcl; if you are ever to do anything serious in programming, you will need to know C anyway, so learning it would only be beneficial _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed Nov 30, 2005 10:37 pm Post subject: |
|
|
You are funny, you could have given me the link for that post on IRC, might have been easier for me to give you a help for your case . _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
|