Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun Jan 11, 2009 3:29 am   

Can someone convert this code?
 
Can any of you programmers convert this code?

Code Here

I'd really like to convert those to functions I can use in Cmud to do the same exact thing.[/url]
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Jan 11, 2009 4:29 am   
 
If you install ActivePerl, you should actually be able to use that Perl code directly, or with minor changes.

I know there was a thread on the forums already about generating patricia trees for long lists (I remember you saying you have a list of about 800 names?) but a search isn't coming up with anything :(
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun Jan 11, 2009 6:13 am   
 
Yeah I have a few lists with hundreds of names. The only thing I am wondering according to that code do all the names have to be the same length?

I don't know any way of changing like my lists of city enemies because I have to update them all the time. :( Right now I dropped it down to a little over 500 but that is still a lot to keep track of.

I just figured that script would make it easy for stuff like my list of mob/monster names that I don't have to add and remove names from all the time.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Jan 11, 2009 8:39 am   
 
No, they don't have to be the same length, and adding and removing entries isn't really all that arduous - to remove one, you just follow the tree down until you find its leaf, and then remove that leaf. Then you check back up the tree one level, and if the parent node now only has one child, you merge them. You keep doing that until you reach a node with more than one child.

Adding an entry is a bit more difficult and requires going as far down the tree as you can and then checking all the leaves of the last node you can reach to see if they start with any of the same characters as the word you're adding. If yes, you split that leaf and add two children for each of the matching strings - if not, you just add a leaf to whatever node you reached.

But yeah, I've never built a regex from this kind of tree before, and doing so would certainly be an adventure in zScript :P
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun Jan 11, 2009 11:11 am   
 
Okay how do I put this into Cmud? I installed ActivePerl.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net