0

I'm trying to come up with a way to generate a grid/level from a seed.

I'm thinking of using a 6 x 6 grid with 3, possible tiles in each. The seed for that would be 108 characters long, i doubt anyone would want to copy 108 char long seed. (the game will probably be on iPhone, so the seed will be entered via keyboard) Anyways of shortening it?

I thought a fun way would be to use words. Separate the the grid into three 2 by 6 lines. and have each line represented by an english word. The player would then just type in 3 words which is a lot easier & gives a kind of name to the level.

Any thoughts on how i could achieve this?

(I'm currently using gamesalad)

Thank you for your time,

Jordan

  • maybe creating a database that maps words to tiles? Also, you will probably need to show what you have tried so far. – jeff Oct 22 '15 at 01:25

1 Answers1

0

Shorting the seed.

Well 108 characters is a little over kill. You have 6 by 6 cell so that's 36 cells total. Each cell has 3 different states yet a char has at min 64 different states (A-Z,a-z,0-9, and a few punctuations to keep it simple) So even with 36 character we have way more than we need.

So lets break it down some more. Computers work in binary. A bit is the smallest bit of information it can use. One bit can be on or off so it has 2 possible states. 2 bits can be off,off or off,on or on,off or on,on so that is 4 different states. If we add another bit we get two more states for every previous state so that is 4*2 = 8 states for 3 bits. Times by 2 again for a 4th bit we get 16 states, again for 32 and again for 64 which just happens to be the number of characters we want to use. So it takes 6 bits to store 64 possible states.

Now lets look at the grid. Each cell has 3 states each. So two cells have 9 possible combination 3*3 and for 3 cells its 3*3*3 = 27 next is 3*3*3*3 = 81 or 3 to the power of 4 cells or 3^4 = 81. We can use this trend to work out how many possible combinations there are for all 36 cells. 3 to the power of 36. That is a big number 150,094,635,296,999,121 or One hundred and fifty million billion combinations.

So how many bits do we need to store that number. I could cheat and ask the calculator but that's too easy,

Let's see, 3 cells have 27 combinations and 5 bits have 32. so 3 cells go into 36 cell 12 times and we have 5 bits for every 3 cells so 5*12 is 60bits. That's a nice round number as our chars are 6 bits each we can shove every possible grid combination into 10 char with some to spare. We have 5 spare combinations for every 3 cells so we have 60 combinations spare 12*5. Darn if only we had 4 more combinations that would be 64 which is 2^6 or 6 bits or one char. We can not take away half a character so 10 characters it has to be. BTW 4 combinations is two bits so take that from our 60 char bits and the minimum number of bits to store your grid is 58. 2 to the power of 58 should be just bigger than 3 to the power of 36.

Thus your grid requires 10 chars. Each being any one of ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:) perfect (8 bytes 4 spare bits)

I pick my first 10 char seed BLINDMAN67 now what?

Blindman67
  • 51,134
  • 11
  • 73
  • 136
  • Wow. I'm not the best at math, but i understand parts of that. Still not fully sure how id implement it though. The idea, is the player would make the 'level' in the editor and be given the seed to share or play themselves. so the seed would more then likely be random. – Jordan Connor Nov 03 '15 at 20:02