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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Fri Oct 20, 2006 4:45 am   

zMud to CMUD conversion and speed issues.
 
I am having difficulties with the conversion of multiple nested %replace() functions not performing as they do in zMud.

The code for both being:
#VARIABLE TestRawRoomContents "control|Two purple dogs, three black cats and an original trader|control"
#VARIABLE TestParsedRoomContents { %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( @TestRawRoomContents, ", ", "|"), " and ", "|"), " (hiding)", ""), " who ", "|"), "k|h", "k and h"), "y|w", "y and w"), "|a ", "|the "), "|an ", "|the "), " is ", ""), " are ", ""), " ", " lounging "), "k|w", "k and w")}
#ECHO @TestParsedRoomContents

In zMud the following is output to the main window:
Code:
control|Two purple dogs|three black cats|the original trader|control
Wheras in CMUD a leading space is added:
Code:
 control|Two purple dogs|three black cats|the original trader|control
This causes problems when I try to delete the 'control' words from the variable. Is there any way I can alter my script so that CMUD does not add the leading space?

Furthermore, I have added echo commands at the begining and end of the code block (of which the above is only a minor portion) and am finding CMUD to be between 5 and 10 times slower than zMud for processing this code even after multiple executions of the unaltered code. If this remains the case then CMUD will be unusable for me, following are some example times:

zMud:

Test 1.
06:09:28:031 Contents detected.
06:09:28:109 Contents processed the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the blue rat|the blue rat|the blue rat|the fat dog|the fat dog.

Test 2.
06:09:28:906 Contents detected.
06:09:29:000 Contents processed the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the blue rat|the blue rat|the blue rat|the fat dog|the fat dog.

Test 3.
06:09:29:765 Contents detected.
06:09:29:843 Contents processed the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the blue rat|the blue rat|the blue rat|the fat dog|the fat dog.

CMUD

Test 1.
06:10:59:973 Contents detected.
06:11:00:955 Contents processed control|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the blue rat|the blue rat|the blue rat|the fat dog|the fat dog.

Test 2.
06:11:02:066 Contents detected.
06:11:03:018 Contents processed control|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the blue rat|the blue rat|the blue rat|the fat dog|the fat dog.

Test 3.
06:11:06:893 Contents detected.
06:11:07:835 Contents processed control|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the fluffy pigeon|the blue rat|the blue rat|the blue rat|the fat dog|the fat dog.


Last edited by Ceres on Fri Oct 20, 2006 5:13 am; edited 1 time in total
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 20, 2006 5:08 am   
 
You have an extra space in your #VAR command. You have:

#VARIABLE TestParsedRoomContents { %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( ...

Notice the space after the { ? In CMUD, {} act like quotes (except that they expand @vars whereas quoted strings do not). So having a space after the { is just like putting a space after a ". You need to change it to this:

#VARIABLE TestParsedRoomContents {%replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace(

In this case it was actually zMUD that was handling it wrong.

As far as speed, you need to remember that this is a BETA product and there hasn't been a lot of speed optimizations done yet. Also, using new features like Local variables and other tricks, it's very possible to speed up what you are doing. I'm sure some of the Gurus will also probably have ideas on how you can speed up your scripts. Scripts in CMUD run faster after the first time because they are compiled, so scripts that run over and over again run faster than scripts that you just run once.
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Fri Oct 20, 2006 5:18 am   
 
Thanks for spotting that Zugg, it was driving my nutty. I'll have to keep that in mind when converting my other scripts.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 20, 2006 4:35 pm   
 
When speed testing, are you putting this all into an alias and then executing the alias, or are you just entering it on the command line. If you have it in an alias that posts the speed results, post the full alias here and I'll play with it.

The compiler in CMUD will only optimize if you put this into an alias. If you just enter it into the command line it's going to be slower than zMUD no matter what I do (because it gets both parsed, compiled, and executed from the command line).
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Fri Oct 20, 2006 6:00 pm   
 
Yes, it is all in an alias. Basically is is initiated from output from the mud to parse into a usable format the contents of 'living' (killable) NPCs. The alias parses the text into two usable string lists, one being singular and the other pluralised. As part of the parsing it is necessary to:
1. Remove any number of different stances (there are 117 variances so far)
2. Convert numbered entities into multiple single entities for the singular list
3. Remove the numbers from the singular list

I have several levels of differing variables to aid in tracking down errors in the parsing which I could clean up eventually, however I will post the code as it now exists as you have requested. The code is from zMud however it works flawlessly in CMUD 1.10 now that I have addressed the extra spaces at the beginning of the lines (in zMud) to conform to CMUD's more stringant requirements.

zMud code
Code:
Code removed as it was not the cause


You may notice the dual triggers, one initiates the alias and the second is to recreate the first in the event that it does not fire when it was supposed to. This was necessary as depending on how much data was being sent from the mud and the load on my CPU the initiating trigger would sometimes cease to function. The use of #priority throughout was my first attempt at minimising the occurance of the trigger not functioning, I have stripped all #PRIORITY commands from the CMUD code.

I will post the exported XML from CMUD in the following post.

BTW.. the timing messages are set to be output to a window with the name of 'Commands'.


Last edited by Ceres on Tue Oct 24, 2006 11:08 am; edited 2 times in total
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Fri Oct 20, 2006 6:04 pm   
 
Code:
This is redundant as CMUD 1.11 has been released - updated code is further down the thread


If anyone can suggest optimisations for the code I would greatly appreciate it.


Last edited by Ceres on Sat Oct 21, 2006 4:30 am; edited 1 time in total
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Fri Oct 20, 2006 6:45 pm   
 
Embarassed I forgot to give you sample code to test it with Embarassed

#SHOW Four orange canaries are standing here, three pink elephants are flying and two fluffy pineapples are sitting here.

#SHOW An agitated architect is standing here, a pink elephants is flying and two fluffy rabbits are standing on the remains of a table.


Last edited by Ceres on Sat Oct 21, 2006 4:04 am; edited 1 time in total
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 20, 2006 8:20 pm   
 
You should go through your aliases and syntax check each one. In your alias:
Code:
#ALIAS InitialRoomContentsAlias {#PRIORITY {#VARIABLE RoomContentsList {}}
 #VARIABLE ContentsNumberReplace {}
 #VARIABLE ParsedPluralRoomContents {}
 #VARIABLE PlayersInRoom {0}
 #IF (%pos( "wisps", @RawRoomContents)) {:1:#SAY %ansi( bold, red)Talker mistrigger!
   #VARIABLE RawRoomContents {}} {#NOOP}
...

you have a syntax error. The space before the #VARIABLE RawRoomContents marks this as a continuation line in CMUD. You need to either do this:
Code:
#IF (%pos( "wisps", @RawRoomContents)) {
  :1:#SAY %ansi( bold, red)Talker mistrigger!
  #VARIABLE RawRoomContents {}} {#NOOP}

or this:
Code:
#IF (%pos( "wisps", @RawRoomContents)) {:1:#SAY %ansi( bold, red)Talker mistrigger!
#VARIABLE RawRoomContents {}} {#NOOP}

or put it all on one line. It's possible the multiline bugs in 1.10 are preventing you from modifying this correctly.

That's all I checked in the limited time I had to mess with it. But it's very important to go through all of your aliases and triggers and click on the "Compiled Code" tab for each to make sure they are all compiling properly. If your code doesn't compile, then it's going to be *really* slow and probably not work correctly.

In general, without better indentation, it's nearly impossible to figure out your complicated script.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Oct 21, 2006 12:27 am   
 
I also found a bug in CMUD dealing with a particular syntax you were using. Syntax like this was broken in CMUD:
Code:
#FORALL @Var {
  VarName={value}}

It was a case of using VarName={Value} with the {} braces while inside a nested statement such as #FORALL or #IF or something like that. Pretty obscure, so I'm glad your example helped me find it.
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Sat Oct 21, 2006 12:30 am   
 
Thanks for the advice Zugg Smile

There are no errors indicated within the alias either when doing Tools>Check Syntax (Ctrl+k) or within the Compile Code tab however I concede that the alterations necessary to the indentation in CMUD make it very difficult to read (even for the author).

I'll follow your advice and recreate it segment by segment just to ensure no errors exist which the syntax checker isn't identifying whils it is one code block.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Oct 21, 2006 1:48 am   
 
Take another look at it when v1.11 comes out later tonight. I think the changes in the multiline syntax might effect it.
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Sat Oct 21, 2006 3:06 am   
 
** updated and tested as working in CMUD 1.11 **

To aid in understanding of the code I have taken the liberty of adding comments to the code as it exists in CMUD. As I was creating it I checked that the code compiled with each addition by both Ctrl+K and clicking on the Compiled Code tab, there were no errors detected. Hopefully this clarifies each line of code, The alias is named InitialRoomContentsAlias:
Code:
Code removed as it was not the cause

There are two variables and a trigger that the preceeding alias are reliant upon, these are:
Code:
Code removed as it was not the cause

All other variables will be created / modified on execution. If anyone can suggest ways to optimise the code I would greatly appreciate it Razz

To test it simply use the examples I gave in a preceeding post from the command line.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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