Archive for May, 2009

Superl

Saturday, May 23rd, 2009

Superl is a project I developed several years ago. It was inspired by a great program I was working with that went by the same name.

Superl is a graphical Perl interpreter written in Perl. It opens one simple window in which you can type in your Perl commands and it will execute these commands for you. Superl also has some nifty features like:

  • Scrolling through the history of commands you’ve entered.
  • The _ function gets the result of the previous command (like ‘_’ in python).
  • Function/Variable completion with ctrl+space.
  • The result of each command is shown in the output window in blue.
  • Prints to STDOUT from your program will be shown in the output window in green.
  • Prints to STDERR from your program will be shown in the output window in red.

Superl runs on both Windows and Unix/Linux. All it needs is Perl and the Perl Tk package.

Superl is extremely useful for performing quick tasks with Perl or for checking out small pieces of code. Superl isn’t meant to be used as a Perl IDE. It doesn’t have any form of file management. It’s meant to be a graphical Perl interpreter.

I’ve registered Superl under Sourceforge as an open source project. It is distributed under a GPL license.

The Sourceforge project homepage is here. On it you can find more details about the project and you can download the project files.

The Game of Evolution

Saturday, May 16th, 2009

I’ve recently added a new page to my website – The Game of Evolution.

This game is an advanced version of the famous Game of Life.  Similar to the Game of Life, the Game of Evolution is a zero player game. The game starts with an initial configuration and the user can watch how the game advances.

In this game animals must survive in a world according to a set of rules. Each animal starts with an initial amount of energy, and loses energy each turn when it performs actions like moving or reproducing. An animal can gain energy by performing actions like sleeping or eating. The animals make their decision as to which action to perform each turn according to their genome. Each animal has its own genome that is transferred to its offspring with a random mutation. The winner of the game is the animal which outlives all the other animals.

It is interesting to study which genomes are more likely to survive in the world, and how small parameters like the length of the genome, the amount of energy spent and gained by different actions and the initial placement of the animals affect the outcome of the game.

The game is located here.

More information on the game rules is located here.

The game is currently in a fairly initial state, so many more features are expected to be released in the future.

I’d be more than happy to hear any comments/ideas you may have. Email me at yuval (dot) baror [dot] website {at} gmail (dot) com

Improved SWIG C# wrappers std_vector.i and std_map.i – part 2

Saturday, May 9th, 2009

* Note: since posting this a new version of SWIG has been released (version 1.3.40). This version includes the improved C# wrappers discussed here. A simple explanation about these wrappers can be found here.

After posting my previous post on the improved SWIG C# wrappers for std::vector (std_vector.i) and std::map (std_map.i) I was contacted by one of the main developers of SWIG, William Fulton. This led me to discover the extensive testing suite that SWIG is delivered with.

I tested my improved std_vector.i wrapper against the testing suite, and this went well. Then I wanted to test my std_map.i wrapper, as it is a complete rewrite of the existing wrapper.  Since there was no existing test suite for the std_map.i wrapper, I created my own test suite for this wrapper. This flushed out a lot of bugs, and the wrapper is hopefully in much better shape now.

Here is the new version of std_vector.i wrapper: std_vector.i

And the new version of the std_map.i wrapper: std_map.i

The two files relevant for the testing suite of std_map.i are: li_std_map.i and li_std_map_runme.cs

These can be incorporated in the existing SWIG testing suite. I tested them on Windows using Visual Studio. I’m also attaching my C++ and C# solutions for this testing suite. To use them – first rebuild the C++ solution, and then rebuild the C# solution and run it. std_map_test.zip

These wrappers will now hopefully be included in the next release of SWIG, though a good code review wouldn’t hurt…