egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Boggle Game Script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
sarius
Voice


Joined: 05 Aug 2005
Posts: 20

PostPosted: Mon Nov 28, 2005 10:41 pm    Post subject: Boggle Game Script Reply with quote

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! Laughing

Any comments/advice/suggestions will be greatly appreciated!
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Nov 29, 2005 1:27 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sarius
Voice


Joined: 05 Aug 2005
Posts: 20

PostPosted: Tue Nov 29, 2005 8:33 am    Post subject: Reply with quote

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 Very Happy
Back to top
View user's profile Send private message
sarius
Voice


Joined: 05 Aug 2005
Posts: 20

PostPosted: Wed Nov 30, 2005 12:46 am    Post subject: Reply with quote

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
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Nov 30, 2005 2:36 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Wed Nov 30, 2005 10:37 pm    Post subject: Reply with quote

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 Very Happy.
_________________
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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber