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
yelayon
Novice


Joined: 15 Mar 2005
Posts: 42

PostPosted: Wed Jun 17, 2009 1:04 pm   

Dijkstra's algorithm in cMud
 
Hello,

I'm going to implement some dijkstra's algorithm in cMud, which I need for mud I play.
To do this I need to store graph connections and write function which implements that algorithm.

I was thinking about using Lua but I dont have any examples for cMud of it (functions and aliases) - mainly how to use cMud variables and Lua variables. How to communicate with mud (# commands??), etc.
I've already read tutorial for Lua (http://lua-users.org/wiki/TutorialDirectory) so I know a little about this script language.

My questions are:
1. What is the best way to store graph (nodes has number from 0 to i.e. 1000) connections considering:
- graph will be static
- graph connection will be updated (mapped) by triggers

I was thinking about %array (but posted but that it doesnt saves) or Lua tables (but probably cannot store it in settings). If I understand Lua variables have only local scope (of alias or function).

2. Writing function
- Lua should be fastest
- JScript - easy for me, b/s already have it in C# and should be easy to move it to JScript
- zScript - hmmm... performance?

In zMud it was almost impossible to do that and now in cMud thx to local scoped variables and ability to recurency should be easy.

Just looking for your oppinions what will be the best
_________________
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Jun 17, 2009 3:23 pm   
 
1) String list variables are converted to/from Lua tables for use in Lua. So if you modify a Lua table associated with a normal session variable, it should save it with the session. Lua variables are GLOBAL within a specific session window. They are not local to an alias or function.

You could also write an "onLoad" event to load your Lua data from a file and it will then be available to your Lua functions.

2) Lua is fastest for the kind of low-level data algorithm you are describing. Definitely do not use anything that uses the Windows Scripting Host (jscript, vbscript) since the support for that is very limited and you will have trouble saving your data across sessions. The Lua interface in CMUD is much more extensive and integrated.
Reply with quote
yelayon
Novice


Joined: 15 Mar 2005
Posts: 42

PostPosted: Wed Jun 17, 2009 4:31 pm   
 
Anyone can provide some more complicated Lua's examples for cMud which will use functions, aliases and variables?
_________________
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Wed Jun 17, 2009 5:29 pm   
 
You may want to look at my patricia tree package in the library - core script is in lua, with zScript interface
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
yelayon
Novice


Joined: 15 Mar 2005
Posts: 42

PostPosted: Wed Jun 17, 2009 5:55 pm   
 
@Arde: thank you - I will look there for examples
_________________
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
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