# Determining the bits needed

4 replies to this topic

### #1 Tl20NOFFLINE

Tl20N

Combat Commando

• 1 posts

Posted Sat Feb 12, 2011 3:40 AM

I read to chapter two of Robert M's tutorial. I understand the idea behind binary, and was following along nicely. Until he gave the formula to figure out the number of bits needed in a given number of variations within a game. Here it is:

The fomula for the number of combinations possible given N bits is:

combinations = 2 ^ N = (2 to the power of N)

So an enumeration of W items will require a minimum of:

N = log2 (W)

Exercises:
------------
Here are some real world examples of enumeration from Atari 2600 games. For each item calculate the minimum bits the program must use to keep track of the particular piece of information.

1. The catridge combat has 27 game variations, what is the minimum number of bits the combat program can use to keep track of the current variation?

2. The 112 game variations for Space Invaders.

3. The Atari 2600 Display is 160 pixels horizontally by 192 pixels vertically (NTSC) To position a player on the screen you must enumerate its horizontal and vertical position. How many bits are needed to store the horizontal and vertical positions of the player?

4. In Surround the "arena" is 40 blocks wide by 20 blocks high. Each block in the playfield is either filled or empty. How many bits are needed to remember the status of the playfield? How many bits are needed to remember the horizontal and vertical position of each player?

I will post the answers in 24 hours.

And even when he posted the answers, it went over my head. I don't understand the formula at all. Could someone please explain this to me?

Edited by Tl20N, Sat Feb 12, 2011 3:42 AM.

### #2 GroovyBeeOFFLINE

GroovyBee

Games Developer

• 8,480 posts
• Busy bee!
• Location:North, England

Posted Sat Feb 12, 2011 4:48 AM

I'm not familiar with the tutorial but the formula :-

N=log2(W)

can be rewritten as :-

N=log10(W)/log10(2)

Which should be solvable on any scientific calculator.

### #3 diogoandreiOFFLINE

diogoandrei

Chopper Commander

• 210 posts
• Location:Brazil

Posted Sat Feb 12, 2011 6:11 AM

N = log2 (W)

It's something like this (some one corrects me if needed!):

We have a logarithm on base 2 and variables N (number of bits) and W. So, if W is number of combinations, try reading the formula like this:

What power will bring 2 (log on base 2) to come close to the value W?

So, if I have N = log2 (8 )

What power will bring 2 close to 8? It's 3, because 2 to the power of 3 is 8.

One more... N = log2 (32 )

2 to the power of what number (N) will give us 32? Answer is 5. Being N the number of bits, that would take 5 bits.

### #4 GroovyBeeOFFLINE

GroovyBee

Games Developer

• 8,480 posts
• Busy bee!
• Location:North, England

Posted Sat Feb 12, 2011 6:17 AM

Don't worry, Tl20N contacted me via PM and its been resolved.

### #5 diogoandreiOFFLINE

diogoandrei

Chopper Commander

• 210 posts
• Location:Brazil

Posted Sat Feb 12, 2011 10:06 PM

cool

#### 0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users