|
yelayon Novice
Joined: 15 Mar 2005 Posts: 42
|
Posted: 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. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: 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. |
|
|
|
yelayon Novice
Joined: 15 Mar 2005 Posts: 42
|
Posted: 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. |
|
|
|
Arde Enchanter
Joined: 09 Sep 2007 Posts: 605
|
Posted: 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 |
|
|
|
yelayon Novice
Joined: 15 Mar 2005 Posts: 42
|
Posted: 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. |
|
|
|
|
|