Written by Ehsan on Monday, May 23, 2011 (2011-05-23) – 22:39:13
Finally came around to check the blog again and realized I needed to update wordpress and 14 new plugins. Which actually went a lot faster than one can imagine… a few minutes.
Now to the point! I’ve been reading up a few days on adding scripting to C#. After looking at Ruby and Python I stumbled upon Lua and I liked it! Ruby is nice, but too complex for my purposes, same for python. Lua isn’t as spread as the former two but it’s really high level meaning it’s perfect for easy scripting with very little over-head. Also it extremely light-weight. Integration took a few hours because I had to build a custom Lua interface (from source code) for .Net 4.0, the default one is compiled for 2.0.
So why did I want scripting in C#? I’ve been working on a little project to create a light-weight MMORPG and now the final (well, graphics, musics etc is missing but hey!) piece is in place. Now I’m able to compile the core and run it, the rest is done by scripting from within the game without even restarting the application (unless any core components need to be rewritten).
Except the custom build from source, this is what was done in less than 30 minutes:
- Lua interface for C# (from custom build), ~5 minutes
- Understanding Lua language by reading reference documentation and some tutorials, ~10 minutes
- Writing static C# functions to interact with a simple Lua script that contains functions and variables, ~5 minutes
- Writing a dynamic C# script creator with error handling and external JIT Lua compilation, ~5
So if you’re looking for a high-level scripting language, that is easy to integrate with C# and complements C#. Check out Lua!
Tags:
.NET,
C#,
Lua,
MMO,
MMORPG,
MUD,
Programming,
RPG,
ScriptPosted under
Programming |
No Comments »
Written by Ehsan on Sunday, September 5, 2010 (2010-09-05) – 17:54:04
A couple of weeks ago I ran across a site that got me very interested. The traveling salesman problem has long been studied in various areas, you can read up on it on wikipedia, here. Of course, I couldn’t resist the challenge! So here’s my take on the problem.
I set up a basic XNA window with mouse, keyboard controls and the possibility to plot out cities. Then, given a fixed set of chromosomes, I create a gene pool and start the evolution process until I get a well suited sample.
Read more »
Tags:
AI,
C#,
Genetics,
ProgrammingPosted under
HowTo,
Nature,
Programming,
YouTube |
No Comments »
Written by Ehsan on Saturday, July 3, 2010 (2010-07-03) – 21:11:12
Came across a really interesting video the other day, well worth spending 45 minutes on and learn how debt is used to create money!
Tags:
Debt,
MoneyPosted under
Blog |
No Comments »
Written by Ehsan on Saturday, June 5, 2010 (2010-06-05) – 12:44:49
Here’s my 4am take on a genetic AI implementation in C#. Application areas? Computer aided design, solving schedule problems, economics, game theory etc. The genetic AI type is among the easiest to understand and a very good starting point, also I suggest adding a dash of mutation to avoid evolutionary dead-locks (=
Read more »
Tags:
AI,
C#,
Genetics,
ProgrammingPosted under
HowTo,
Programming |
No Comments »
Written by Ehsan on Monday, May 3, 2010 (2010-05-03) – 06:38:27
Here’s a small app I wrote for retrieving currency exchange rates from different sources. Currently it’s hard-coded to only get the rates from www.xe.com but more will come. Since xe.com doesn’t have a API I decided to retrieve the selected exchange rates with a simple HTTP GET request. Unfortunately this means that it will stop working if xe.com changes anything in the first 306 bytes of the site…
You can download it here.
Tags:
C#,
ProgrammingPosted under
Programming |
No Comments »