Why I dismissed DynamoDB And Redis in favour of MongoDB

As I was writing some time ago about how I’m utilizing redis (redistogo) and amazon DynamoDB as a well performing combination of two services for my facebook-app ZeroPilot. I have to decided to drop this system and use MongoDB via MongoLab as a heroku-addon.

Why the change


1) From the beginning on I was not to certain about using DynamoDB – since DynamoDB is a very fast and very reliable db-system I wanted to give it a try. However, DynamoDB has some (in my opinion irritating) flaws. For example all numeric values will be saved and typed as ‘BigNumber’ so in Ruby e.g. before you can really work with the values from the db you have to cast them to integer or any other type that suits your needs. Also there was no way (yet?) to export data through the AWS console, also there was no way to edit data, only recently a feature was added to view data inside a table.
Continue reading

Generate Repeatable Random Numbers (in JS)

Quite often when developing a game I need “random” numbers, that I can reproduce or that I can steer. Why? – For example when setting up a level or when resetting a level you might want to have it look random, but still the same every time you load it. – So how do we do that? There are tons of ways of achieving a so called “seeded random generated number” – if you want any details on the algorithms you can for example check out this link. But basically they all work the same: You initialize the algorithm with a “seed” (a number, that you choose to steer the algorithm). And every seed will return its own unique set of “random” numbers, so e.g.: Every time I seed the Number 6, I get the same set of generated “random” numbers. Every time I seed the Number 10, I get the same set of “random” number, that is different from the set ‘6’ and so on…
Because of this fact: seeded random numbers are predictable, which is not bad, but just don’t use it for encryption purposes ect… ;-)

The algorithm


So the algorithm I’m using is the following, it’s really very simple:
(this is nothing new and also nothing I invented, but I think this might help quite a few people)

Continue reading