Wednesday, November 2, 2011

d-jon is going to the open source world!

After 1 year of hard work I decided to open the code to the world, why? easy because I always wanted to give something to the community, I used several tools based on open source and I think it's good to give something back.

How d-jon started?


2 years ago I was working on the java version of Bizagi (http://www.bizagi.com) and the team started to use TSP (Team Software Process) in order to develop the new rendering module, one of the key features of TSP is the ability to measure the time spend on every single task you do on your job, that's how I started to use several linux tools to track my time and all of them were unsuccessful, most of the tools because they're unable to track if I'm working on my desk or leave the office soon, if I forgot to stop the timer when I decide to take my lunch then I had to get back and pinpoint at what time I leave the office, same happens when my boss (or a coworker) ask me a question about some other subject, when I come back to my desk I did not know how much time I spend assisting somebody else, one of the tools lost all my records without any warning, etc etc... I got tired of this and decided to create a simple tool to track my time.

Some months later I realized that my tool was getting stronger, and stronger, so I decided it worth the effort to put d-jon on the web, that's how I did the first refactor of all the code to create a less buggy application, at first I was the only user so I can deal with some bugs, but now that the application is going to be on web I have to fix them.

Vision Software, the company I have been working for 7 years, decided that this tool was good enough to replace the Allnetic solution that was buggy and has several issues. 1 year later d-jon has over 10.000 downloads and it is been used in several Countries, I'm pretty happy that it filled the gap between professional solutions and the free ones.

Why going open?


First of all, one of the most difficult tasks is to get some feedback from the users, not because they don't want, just because there is a lot of spammers out there willing to put porn and viagra ads in every site they can, I started a forum and tried to keep the spammers out of it but was a futile war, they won... crash and burn me, I do not have the time to deal with web issues, and be a policeman of every post on my site, that's why I closed the forum, I had to spend too much time deleting spam messages, then figuring out how to keep the spammers out, etc... I prefer to use that time to improve the application and not to keep these unwanted people out of my life,

So, what if the users do the extensions and fit the tool to their expectations? that's why I decided to open the source code, to let the users improve it and get the best from the tool.

What's comming?


I need to do several things before publishing the code, like license to be used, put all the documentation about the code, create a standard structrure (make and all of that stuff), etc etc... but I thing it worth the effort.


Sunday, October 23, 2011

My own NoSQL DB, progress


The last few weeks have been good... hard... but good, I finally implemented some new layers in the DB, some of them were harder than others, and i realized that I dont know that much of some bare metal components like network layers as I thought I know, but anyway I managed to pass through all of this and the db is now running smoothly, this post is to write down some of the progress made and explain some of the problems I had implementing these new layers.

Command Layer 

This component is really one of the cores of the communications with the user, basically it's meant to process the commands made by an external player and figures out what is the request, how to handle it and what is expected to be returned to the client.

This component was not really a problem, basically because I already knew how to handle the network protocol, then I wrote a writer and a reader and that's it, the command is alive!.

Network Layer

This component was really a hard ball, I didn't know that synchronize the sends with the reads will be that hard, this component drove me crazy for some days, until I realized that I had the network layer does not sign a contract with you to send exactly what you put on the pipe, thus is not suppose to get the expected length at the end of it. Let me put it this simple:

Client A writes 1000 bytes on the pipe.

Server expects 1000 bytes...

But... that does not happened, the client actually sends some chunks of data, 100 bytes at first, 500 later, 200... etc. Thus the server should expect to read this mess in the same way, now that I read some literature about it (that's why it took me 1 week to implement this layer) I know that it's easy... but this layer was a real pain (if you have questions about this, just let me know and I will try to explain how to create a reliable server/client communication), I still to do some improvements in order to get better performance, but anyway it's working right now and I dont want further delays in this project.

Index implementation

Here's the tricky part of the databases, figure out how to create an efficient way to sort the data in order to retrieve ii later, in this part I tried to avoid the conventional methods, and try to figure it out from my own knowledge... big mistake!... hahahaha, anyway this tries outs were good to understand why the people came out with fancy solutions like B+Trees, BTrees, etc. here's the BUT... I read documentation on B+trees and it didnt fit well on what I think should be the separation between data and indexes, so I had to create my own solution to this problem, of course... based on B+trees knowledge and some of my tries outs.

Now, the tests runs very well... the db gets the following output:

20000 inserts per secs and 29978 finds by key operations per sec.

The thing with the network layer is not going that well, but I will fix this later, with the network layer on the output is: 8695 ops, close to the achieved output of MongoDB which makes me very happy for now. I know that when the time comes I will fix the network issues and that will be a nice boost for my server.

Later I will create some posts of my learning process and what problems I had to solve in order to keep on with this project.

The project keeps looking good, and I will keep going on.

Thursday, September 22, 2011

My own NoSQL DB

15 days ago I read this article: http://blog.cubrid.org/dev-platform/nosql-benchmarking/ and got shock with the amazing performance, c'mmon! 21k operations per second? it's amazing...

After a long bath I started to wonder, how much performance will I achieve if I create my own NoSQL database, just an experiment for those rainy days, ok... here I am 1 week later after some hard work, I created my own NoSQL Database which is capable of:

1. Insert Records
2. Find records using the key (that's the benchmark)
3. Index the keys and whatever I want to index to find records later.
4. Split files to get indexes separated from data.
5. Created a layer to save the data using little endian (basically I copied the code from my other project d-jon)

Here's the test I did, with a modest machine and 8Gb of RAM:

1. 1M inserts of 1k (I know, the bench was over 50M, but I dont have free space on my machine right now)
2. A random search using random keys (300.662 searches)

And here are the stats:

the inserts took 23.48 secs, which means 42.584 operations per sec.
The searches took 20.3 secs, this means 14.763 operations per sec.

These results are preliminary, but I'm starting to think that I could beat MongoDB, Cassandra, and others,

I started my project because I was out of challenges, and it's turning to be a very attractive project, maybe this could be my next fulltime job.

A lot of work coming, but what the hell... djon started just like that and now have over a 3k of downloads and users all over the world.

Wednesday, August 17, 2011

C++11 C++x0 new C++ is here!

At last, after almost 3 years the new standard has become a reality, this new standard has a lot of cool features that I will try to cover within my next posts.

Follow the link for The C++ Standards Committee if you want to get a "light" read and have an understanding of what's going on with C++11. Or just keep connected because I will try to explain the major changes about the standard.

Thursday, April 21, 2011

Almost completed

Ok, my game is almost complete, at least the main idea, interaction and elements required (graphics, sounds, gameplay, etc), during the last 3 hours I created the level system, an explosion animation (I didn't find an animation that suites my needs so I need to create it from scratch using gimp and imagination), I also added sounds.

In Addition, my tester (my 4 years old son) did a test and I think it worked as expected, everytime he see me on the computer ask to play the game again and again... the magic is done!

Now I need to work on the following things:

1. The health of the UFO
2. The health of the player
3. The fight back from the UFO (easy with the engine I created)
4. An score system.
5. More sounds.

At this rate I think I will finish my first game in 1 week (or less if I have time during my vacations).

I'm very happy with the current results and I will share some demos of the code (not the one used in the game, but I will manage to create some demos of how I used SDL in my first game).

Tuesday, April 19, 2011

Week 2 Results

Then game is going pretty well and Im starting to love this new career, the results are very good (from my limited and biased point of view) and I want to share the results that I got till now,

Game Engine:

The main idea of a game engine is to create something that you could reuse easily on other projects and avoid the creation of the code from scratch everytime, my 2d game engine has the following features:

  • Image loads (maps, sprites, etc)
  • Movement (gravity and simple movement from left to right)
  • Event managed in a proper way
  • main loop routine
  • Collision detection

So far this is a very good result for the second week of work. But I didn't start this from scratch, the www.sdltutorials.com was a very good help in order to understand where I needed to start from.

Game Content:

This was a little bit difficult, I changed my mind several times about how the game will be, cause everytime you see the screen you want something different, it's hard to keep the original idea because you see how the gameplay will be and then you will change the way you thought it's going to work at the first place, but anyway... that's the idea, improve, adapt and get the best from the game.

Most of the spend time was trying to figure out how to create the images you need to put on screen, I tried to create them from scratch but was a big failure, that's why I decided to google a little bit and found some images that I could modify to create the background of my game, also the ufo was taken from a picture found at google, removed the background and get the ufo out of the picture, the cannon was harder but I found a nice place with tons of sprites that I could use (I will post his link in here later), the missil was created from scratch using inkscape (very good tool).

The mathematics was a little bit tricky but finally I managed to create the cannon effect of following the ufo and also the missil will goes into the direction of the UFO's center.

The results of the second week were saved in a video



Hope you liked the progress and if you have any questions I will be glad to answer them.

Shoot the missil: Maths in action!

I came across a problem these days, how can I send a bullet right into the direction of another target, here's when you need to get back into the school and use your Pythagorean theorem knowlegde,

After spending some hours trying to solve a simple equation I realized that I've to get back to the math books, I found a very good discussion about this subject in yahoo answers what you need to know about maths in order to create games.

Ok, I wasted 2 hours into this equations and then remembered something (very blur btw) about vectors, how they should be used to move a point into the direction of a line (vector), that's how I crossed with this: http://www.gamedev.net/topic/600086-find-point-between-2-points/ actually the problem was very easy to solve:


p1x=1;
p1y=1;
p2x=4;
p2y=4;

dirx=p2x-p1x;
diry=p2y-p1y;

p3x = p1x+dirx*0.25;
p3y = p1y+diry*0.25; 

First you need to find the direction of the vector, you get that doing a substraction between the 2 points (x2, y2) - (x1, y1), now that you have the direction you should apply it to the new point and that's it. easy right?

Now my game has a beatiful rocket moving into the direction of the UFO, one step further in the game creation.