GamesPortfolioNewsContact

Shuffling a collection

August 9, 2012 News

The question

In many games you must add some randomness and that might include shuffling a collection of data.

When playing cards with friends, in real life (whaaa?!) you always hear “shuffle them again, they aren’t well shuffled enough!”, so with a proper Penn & Teller face you keep shuffling the cards, many many times, until enough randomness is introduced.

Translating this in code-land, is enough to do

shuffle(cards)

just one time, or must we do something like:


shuffle(cards)
shuffle(cards)
shuffle(cards)

If so, how many times?

What I asked myself is this: if I shuffle the collection twice, will it be more shuffled or, on the contrary, less shuffled than if I shuffle it only once?

Consider the following collection, unshuffled:

[A, B, C, D, E]

Now we shuffle it and get, for example:

[C, D, B, A, E]

My concern is that if I shuffle it again, the items might pop back in in their original place, hence making the collection less unshuffled. Can this happen? Or will it be just coincidence?

But first, how do we define a distance between collections?

Two ways, that I can think of, are:

1) Positions

Sum the difference of the positions of the elements between them.

With this method we iterate item by item for the first collection and found on which position on the other collection the item is, and calculate the difference between positions. Easier to see with pseudo-code:


int distance(List list1, List list2) {
  int ret = 0;

  for (element : list1) {
    ret += abs(list1.indexOf(element) - list2.indexOf(element));
  }

  return ret;
}

2) Permutations

Sum how many permutations must be done to the second collection so that it’s on the same order as the first collection. Again, some pseudo-code:


int permutations(List list1, List list2) {
  int ret = 0;

  for (T element : list1) {
    int posList1 = list1.indexOf(element);
    int posList2 = list2.indexOf(element);

    if (posList1 != posList2) {
      temp = list2.get(posList1);

      list2.set(posList1, element);
      list2.set(posList2, temp);

      ret++;
    }
  }

  return ret;
}

With these two über powerful tools, we are ready to find da answer to the question.

The idea is to try and see the distances between the original collection, and a shuffled collection, and compare the results with 2 shuffles, 3 shuffles, et cetera.

Results

Size 5

Size 5

Size 10

Size 10

Size 25

Size 25

The raw data is uploaded here as a google doc

Hence, it’s straightforward: shuffle them as many times you feel like, they’ll have the same entropy

tl;dr: it doesn’t matter how many times you shuffle a collection, as long as the shuffle function is ok, it’s all the same

Global Game Jam in Argentina

December 26, 2009 News

The 2010 GGJ will take place January 29-31, 2010 in more than 30 countries around the world including: Argentina, Australia, Belgium, Brazil, Canada, Denmark, UK, Finland, France, Germany, Ireland, Israel, Italy, Japan, Lithuania , Mexico , The Netherlands, New Zealand, Norway, Philippines, Portugal, Qatar, Scotland, South Africa, South Korea, Spain, Sweden, Turkey, USA, Venezuela and Colombia.

Game Jams foster innovation and experimentation. If you have ever wanted to make a game, be a part of a team, or go outside of your usual working method, then a game jam is for you. It’s all about making games and in the GGJ you’re part of a global experiment in creativity. A game jam is not for the faint of heart though. It’s two days of hard work, experimentation, little sleep, collaboration, cramped quarters, new friends, great idea, laughs, technical issues and the time of your life.

In this edition, we are proud to announce that, at least for now, two Argentinian cities are participating in the GGJ: Buenos Aires and Santa Fé.

In both cases there is no entrance fee, but there are limited availability. In order to sign up or for further information, visit the Global Game Jam site or http://gamejambsas.wordpress.com/ (Buenos Aires, in spanish) or http://gamejam.videojuegossantafe.com.ar/ (Santa Fé, in spanish)

Alternate Reality Games

July 5, 2009 ARG

Alternate Reality Games, a.k.a. ARGs, are for sure a hard thing to define.

Aristotle said with his ancient wisdom: “don’t try to define an ARG, better show a couple of examples

Before that, I’ll like to show an image that, in my opinion, is ARGs in a nutshell (stoled from Andrea Phillips)

ARGs

Alternate Reality Games

Now we can answer: what is an ARG?

The answers, in no particular order:

Zona Incerta (portuguese)

Year Zero

Find The Lost Ring

Art of The Heist

Why So Serious?

The Lost Experience

I Love Bees

Talking @ GDC ‘09

February 25, 2009 News

This year I’ll be going to the GDC, and I even get to talk a little about Darkstar on a lecture!

If you would like to meet me there, just send me an e-mail (andres at jengibre), leave a comment or just go to the contact section.

See you there!