Archive for the ‘development’ Category

Beloved Software

Tuesday, February 26th, 2008

Here’s a list of free software tools and libraries that I have come to love.

TCLAP is a Templatized C++ Command Line Parser library that makes your wildest command line parsing dreams come true. Its usage is so simple, it’s almost ridiculous. But it not only has all the features you can imagine but also comes with very well written manual.

Next is Prototype, the famous JavaScript Framework that turns formerly painful JavaScript development into a breeze. I just love how easy it is to develop with Prototype. It hides browser dependencies and makes code readable.

A very special piece of software is TiddlyWiki a reusable non-linear personal web notebook. I use it to document my research and write my thesis. It’s ingenious. In some sense it can also be seen and used as an archive that puts documents into context.

When it comes to text editors I’ve been in love with Vim ever since I attended my first C lectures. When used to the interface code editing at the speed of light is possible. To be fair I also like Notepad++ very much.

When it comes to graphics, layout and design I rely on Inkscape – an extremely powerful and easy to use vector graphics editor. It’s under heavy development and great features are added almost every hour. Nevertheless it is very stable.

I’ve been looking for decent UML modeling tools forever. Seriously. There’s a whole bunch of them out there and I tried a lot of them. Until recently I have been unable to find one that doesn’t suck. Then I discovered BOUML. It’s free and fast. Despites its plenty features it doesn’t come across bloated or sluggish.

Speeches, talks and presentations

Thursday, January 10th, 2008

One of the draft blog-posts that has been piling up forever is an assorted list of interesting videos of speeches, talks and presentations. Right now seems to be a good time to share them.

But first of all a list of great video-talk sources:
www.ted.com the website of “Technology, Entertainment, Design” featuring great talks given by for example Al Gore
google techtalks the google tech talk youtube page
www.bigthink.com a new place featuring interviews from all kinds of important and intelligent people about all kinds of topics
www.videolectures.net a place that provides free and open access to high quality video lectures presented by distinguished scholars and scientists.

And here the talks I really enjoyed listening to in the last weeks:
7 Habits For Effective Text Editing 2.0 a talk by Bram Moolenaar, the creator of VIM about efficiently using VIM
Resource Aware Programming a very interesting talk by Walid Taha
Linus Torvalds on git and git by Randal Schwartz
Quicksilver: Universal Access and Action by Nicholas Jitkoff the creator of Quicksilver – an extremely interesting and inspiring talk

CUDA Link Collection

Tuesday, November 6th, 2007

Here’s a list of CUDA related things on the web. CUDA stands for Compute Unified Device Architecture and is a GPGPU technology created by NVIDIA that allows a programmer to use the C programming language to code algorithms for execution on the GPU. The official website can be found here.

Update: NVIDIA introduced the new CUDA Zone website: http://www.nvidia.com/cuda a convenient way to access everything related to CUDA.

If you happen to know more CUDA related links (e.g. projects that use CUDA) feel free to leave a comment.

VTK read and display 2D raw data

Tuesday, August 7th, 2007

In order to create a simple 3D and 2D data visualization tool I took a look at the Visualization Toolkit. I found everything I needed there – it’s a really great collection of C++ classes with bindings for various other programming languages (TCL, Python). However the documentation is somewhat confusing and lacking simple basic things although a very good document on how to install compile and use it together with Visual Studio can be found here and a great blog aiming at overcoming the lack of tutorials can be found here.

I had quite a hard time figuring out the easiest thing: read raw 2D data and visualize it. After I played around with it for a while I figured it out. It’s actually pretty simple. Here’s the code:

/*******************************************************************************

    Simple VTK Example

    A very simple VTK example - a raw 2D datafile is read
    it's magnified by a factor of 3 and then it's displayed on a window.

    The pipeline:
    vtkImageReader->vtkImageMagnify->vtkRenderWindow

    The image file is a raw file of 64 rows * 64 columns. The values are
    2 byte (short int) long. 
    It's a greyscale dataset (NumberOfScalrComponents = 1)

*******************************************************************************/

#include "vtkImageReader.h"
#include "vtkImageViewer.h"
#include "vtkImageMagnify.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"

#define IMG_FILE "C:data.raw"

int main (void)
{
  vtkImageReader *imgReader = vtkImageReader::New();
    imgReader->SetFileDimensionality(2);
    imgReader->SetFileName(IMG_FILE);
    imgReader->SetNumberOfScalarComponents(1);
    imgReader->SetDataExtent(0,63, 0,63, 0,0);

  vtkImageMagnify *imgMagnify = vtkImageMagnify::New();
    imgMagnify->SetInputConnection(imgReader->GetOutputPort());
    imgMagnify->SetMagnificationFactors(3, 3, 3);

  vtkImageViewer* imgViewer = vtkImageViewer::New();
    imgViewer->SetInputConnection(imgMagnify->GetOutputPort());

  vtkRenderWindow *renWindow = vtkRenderWindow::New();
    renWindow->AddRenderer(imgViewer->GetRenderer());
    renWindow->SetSize(64*3, 64*3);

  vtkRenderWindowInteractor *renWindowInteractor = vtkRenderWindowInteractor::New();
    renWindowInteractor->SetRenderWindow(renWindow);
    renWindowInteractor->Initialize();
    renWindowInteractor->Start(); 

  return 0;
}

All new

Thursday, July 19th, 2007

All new on the echelon blog. The layout has undergone a severe design rework – it looks much prettier now. Also check out the supercool new navigation and blog-description.

Suomenlinna

The blog is now driven by Wordpess. Even the hosting changed as this webserver now runs on one of those new fancy server grids. Took long enough to make those changes but now everything is running very smoothly again and new posts are about to come. As for the RSS feed: it is now located at http://www.soa-world.de/echelon/feed/.

Good Games

Monday, April 9th, 2007

No, this is not about the coolest, best and most spectecular new video games but about good video games as in “doing good“. HopeLab a non profit organization in the area of San Francisco has dedicated itself to combine rigorous research with innovative solutions to improve the health and quality of life of young people with chronic illness.

Their first and most popular product is Re-Mission, a “challenging, 3D shooter with 20 levels that takes the player on a journey through the bodies of young patients with different kinds of cancer. Players control a nanobot named Roxxi who destroys cancer cells, battles bacterial infections, and manages realistic, lifethreatening side effects associated with cancer”. Watch the making of video here.

The other game might not entirely fit in the category “good game” but it’s another exepctional game. PeaceMaker by Impact Games is a game where you either play the Israeli Prime Minister or the Palestinian President. It is inspired by real events in the Israeli-Palestinian conflict and your goal is to achieve a two-state solution in order to bring peace to the region. Read an extensive game review on Gamasutra here.

I like the idea of games that “do good” a lot and I’m wondering if a MMOG such as a browser game could be designed to do good too.

Javascript Game Engines

Sunday, March 11th, 2007

Here is a roundup of Javascript Game Engine prototypes. I’m very interested in this stuff and I implemented a very simple prototype myself some time ago. There are two very different types of engines: one group is able to render some sort of map, suitable for strategy or arcarde games. The other group consists of first person 3D engines, suitable for e.g. car racing games and shooters. Here are two examples for the first group:


Ajax3d Demo and Freevolution – an Isometric Map Engine

Both engines seem very cool and very advanced. I’m looking forward to games that use this kind of engines. Such games could combine appealing graphics found in conventionel computer games and the fun that massive amounts of players bring to a game as browser bases games are noted for. I predict sheer infinite possibilities.

The second group of engines is not as attractive as the first one. The reason for that is simple. Games like shooters and car racing games are attractive because they look good. Because they look very realistic. Because they have fantastic effects. Javascript based games could not ever compete with regular computer games in this area. However if one is inventive and has a great game concept I definetly see a future for those kinds of engines too. Here are two examples:


Canvascape – “3D Walker” and HTML Canvas Element real 3D Demo

Browser Games and Software Engineering

Thursday, February 15th, 2007

I recently started writing (yet another) browser based massively multiplayer online game (MMOG) engine. Nothing to fancy, very basic and simple stuff. And I’m of course nowhere near finished. However I spent a considerable amount of time thinking about the fundamental design from the standpoint of a software engineer. This article describes what I came up with.

The very basic design pattern
As all well coded modern applications implement the model-view-controller design pattern I tried to adapt this princible. The pattern facilitates splitting the application into three layers: the model, the view and the controller.

The view (or user interface) represents the data in a convenient way for the user and enables him to trigger certain actions, request data and so on.

The controller (or in my case the game logic) embodies the actual game logic. It is capable of processing and responding to user requests or events in general. A ticker object (a piece of code that updates the game regularly) would also fit into this layer. Additionally it contains a data-link, to connect the controller and the model layer.

Finally the model layer. It represents the game data. In browser games this is often a database of some sort. In my case it’s a shiny PostgreSQL 8.2 database.

The advantage of this pattern is obvious: by decoupling data presentation, business logic and data access/storage the layers may be altered independently. It also simplifies development by reducing the complexity of the engine. Additionally it allows developers to work on different problems, e.g. say a web designer develops the user interface whereas the PHP developer creates the game logic. The developers simply have to define the interfaces between their layers. That’s all they need to know of each other.

Decoupling of the presentation layer nowadays is often achieved by using some sort of template engine. A really cool thing! A detailed description of the mvc design pattern can be found on here.

Controller and Model Design
So far I have designed the controller and the model layers. The following pseudo class-diagram visualizes the concept:

The view layer is not yet implemented. However I plan to allow the user interface to send REST requests to the controller layer. There the received data is validated and the user is authenticated. Then the business logic processes the event, requests some data from the database via the data link, compiles the data together and triggers an output class (XML) to return the data to the user interface. Very straight forward. The user interface hopefully knows what to do with this data and represents it accordingly.

Implementation Consideration
I have already implemented the classes in the diagram shown above. I had to make several choices:

Error handling is a difficult and vital point of the design. I followed one basic principle: only the main class (the business logic class) is allowed to handle errors. Errors occurring in other modules are passed through to the business logic class. This is, in my opinion, vital to maintaining a clearly arranged engine. To return errors I used simple function return values and exceptions. PHP supports a very cool and straight forward exception system (with cool try and catch blocks). Exceptions are also a great way to report errors that occur in a class constructor. However I did not stick with exceptions exclusively because sometimes return values are much easier and faster to implement.

Data validation is a two layer task: first I check if the user tries to foist bogus data on the engine. This can be done with regular expressions and preg or ereg. The second layer ensures that the user does not try to do anything he is not allowed to, like reading someone else’s messages or building more soldiers than he can pay for.

Free Stuff
In case you are interested, the images are created with the ingenious 0.45 version of Inkspace. It’s totally free and really cool. A ZIP file containing the source of the images can be downloaded here. The gorgeous icons are taken from the Tango Desktop Project. A larger version of the second image can be found here. As soon as I finish parts of the game I will put the source code online.

Flickr Photostream Plugin

Sunday, January 7th, 2007

Finally there was time to complete the Flickr photostream plugin for the blog. It’s a script that fetches the three most recently added images from a special flickr photoset.

It makes use of the ingenious script.aculo.us Javascript library, which is based upon the fantastic Prototype framework. For the XML parsing of the Flickr output I used this tutorial here. Quick and dirty but working. To create the shaded borders I heavily depended on this nice tutorial.

As I feel like sharing, the PHP file can be found here. It will not work for you out of the box as I am making heavy use of CSS in the output. For the script to work correctly the script.aculo.us library also has to be included into the webpage.

SQL Magic – Automatically Creating Lookup Tables

Tuesday, November 28th, 2006

I recently had to write a script that would import large amounts of data (~50MB) into a PostgreSQL database every night. I thought long and hard about how this could be accomplished best, I read a lot about it on the usenet and so I decided that the best way would be to use PostgreSQL’s COPY function. The data is available in a .CSV format so everything worked very smoothly.

However after the data is imported it also shall be searchable very easily. Therefor I let the import script create indexes on the data. And as I like to organize and normalize data I thought about a way to automatically creat lookup tables. The following picture describes what I did:

create_lookup_table

This describes the steps necessary to create the lookup table:

  1. We try to delete an probably already existing lookup table.

    DROP TABLE #LOOKUP_TABLE#;

    Delete the table #LOOKUP_TABLE# if it exists.

  2. We create a new lookup table.

    CREATE TABLE #LOOKUP_TABLE#
    ( id SERIAL NOT NULL PRIMARY KEY,
    #LOOKUP_COLUMN# #LOOKUP_COLUMN_TYPE#);

    Create the table #LOOKUP_TABLE# with one column called “id” which is the primary key and a second column called #LOOKUP_COLUMN# which is of the type #LOOKUP_COLUMN_TYPE#.

  3. We fill the lookup table with the values from the large data table.

    INSERT INTO #LOOKUP_TABLE# #LOOKUP_COLUMN#
    (SELECT DISTINCT #DATA_TABLE_COLUMN# FROM #DATA_TABLE#);

    Insert the following data into the table #LOOKUP_TABLE#: every distinct piece of information in the column #DATA_TABLE_COLUMN# from the table #DATA_TABLE#.

  4. We add a column to the large data table that will hold the reference key to the lookup table.

    ALTER TABLE #DATA_TABLE# ADD COLUMN #LOOKUP_COLUMN#_id INTEGER;

    Add an INTEGER column to the #DATA_TABLE# and call it #LOOKUP_TABLE#_id.

  5. We fill that column in the large data table with the appropriate key.

    UPDATE ONLY #DATA_TABLE#
    SET #LOOKUP_COLUMN#_id = #TARGET_TABLE#.id
    FROM #TARGET_TABLE#
    WHERE #DATA_TABLE#.#DATA_TABLE_COLUMN# = #LOOKUP_TABLE#.#LOOKUP_COLUMN”;

    Now comes the cool part: We update the #LOOKUP_COLUMN#_id column in the #DATA_TABLE# table. We write the the id into that colum whereever the #DATA_TABLE_COLUMN# from the #DATA_TABLE# matches the #LOOKUP_TABLE_COLUMN# from the #LOOKUP_TABLE#.

  6. We create a foreign key on that referencing column.

    ADD CONSTRAINT #DATA_TABLE# #LOOKUP_COLUMN#_id_fk FOREIGN KEY (#LOOKUP_COLUMN#_id) REFERENCES #LOOKUP_TABLE#(id) MATCH FULL;

    Here we simply add the foreign key #LOOKUP_COLUMN#_id_fk to the #DATA_TABLE# on the #LOOKUP_COLUMN#_id column.

  7. We delete the old colum that holds the original values.

    ALTER TABLE #DATA_TABLE# DROP COLUMN #DATA_TABLE_COLUMN# CASCADE;

    Here we drop the #DATA_TABLE_COLUMN# in the #DATA_TABLE#.

I will probably post a PHP function that does all the above on phpclasses.org in a few days.