Earlier this week I was involved as consultant into analysis/design task of the crafting feature of social game. The player is doing some actions, actually clicks. The result of such action would be a random set of special items, or maybe just one item, or even nothing. Later player can combine several items to create (craft) some special unique item. Each simple item i has its own probability pi to appear after single click. There is also the approximate number of actions it needs to click for getting all simple items of the combination with some acceptable probability (let’s say 0.5). The goal is to gues the number of instances of each simple item. All simple items appear independently. So, we can use binomial distribution to choose some suitable values.
Combination of items i1,i2,…,in should be collected in N clicks with probability 0.5.
CkN * pk * (1-p)(N-k) >= 0.5
for every item in combination, where p is the probability of simple item and k is the number of appropriate simple item instances in the whole combination.
Excel spreadsheets tool has implementation of formula above as standard BINOMDIST() function already. So, it’s easy to do such calculations for game designers.
Some time ago I designed very efficient pattern of top-n table implementation for social games. There are a lot of users (few millions). Our goal is quickly compose top-n table for any user. Generally, each user has its own top-n table, because the table contains information about the user either he’s in the top or not. Let’s assume users has the score and we build the top-n table by that score. So, most top user in the table (rank=1) has max. score.
As we have social game, so, it’s ok to have not exactly actual top-n table, but some version cached for an hour or 20 minutes. We will update the table in the cache every 20 minutes. The question is about how to represent information of the user (current one). His score is available, but his rank in the actual top-n table is not available if the user is not in the top. It should be calculated on fly. Keep in mind, that we don’t cache whole users table ordered by the score, but only n top records.
The idea is to avoid full table scan but and use linear interpolation to gues approximate rank for user out of top table.
If user has the same score as last user in the top then the rank is N+1.
In other case:
rank = -(UsersCount – N – 1)*(score – Max)/Max + N + 1,
UsersCount is total number of users,
N is the size of top table,
score is the score of the user,
Max is the score of last user in the top table.
Last week I finished with desing and implementation of tournaments feature of our social game about army.
Taking just raw idea of the tournament I’ve done both the server side (C#.NET+MSSQL) and the client side (Flash+ActionScript3), communication protocol, designed gameplay workflow and formalized details of UI for artist to make art. As result, there is a nice feature in the game.
One more time I have ability to prove the ability to work very productive as both the client side and the server side developer beyond the opinion of other people who claimed that it’s impossible.
Already several months I’m working on “Great Empire“. It’s a game for social network. For now it’s already customized and successfully used in several networks. It’s really insteresting project with huge amount of different tasks: Flash/ActionScript 3 client side programming, server side, DB and performance optimization, game desing. I’m very happy to be useful not just as software developer but as project manager and analyst as well.