This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-20 21:16:04

MrMokey
Scratcher
Registered: 2009-05-06
Posts: 1000+

Compressing A Number

So what I have is a square that will stamp itself in a grid across the screen. The fancy thing is, the square changes costumes every time to 'render' a picture.

It does this by using a 180 character code in a variable, where each number represents a costume. A script transfers each number into a new item in a list.

My problem is that I want people to be able to share their codes so that they can render each others creations. This is a bit of a problem as it would require 180 numbers to be typed out.

My idea was that I could divide the large number by 20, and then when I wanted to render it it would just multiply it by 20. This became a problem because the numbers 1, 2, 3, 4 don't divide that well. My idea was to make the costume names 20, 40, 60, etc.

Scratch decided that the costume names have to be 21, 41, 61 etc. etc. and is really frustrating.

Does anyone have any better ideas on how to make the number smaller or how to fix the costume names?

Here is the project with a direct download from my dropbox:

https://dl.dropbox.com/u/35308512/rende … e%20wip.sb


http://i1193.photobucket.com/albums/aa344/mrmokey1/Thankyouitfitsperfectlysig.png

Offline

 

#2 2012-10-20 21:38:59

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Compressing A Number

Okay, 180 characters.  I'm assuming they're digits between 0 and 9.  There's no real way to compress something like that.  There are simple "loss-less" compression techniques that take into account consecutive digits, but that doesn't guarantee a smaller size.  Check out this Wikipedia article

Dividing by a number won't do the trick, since you'd still end up with decimal places at the end.  And dividing by 20 would reduce the size of the number by only 2 digits at most. 

You could display the data in a list and allow the user to copy/paste.

Offline

 

#3 2012-10-20 22:49:18

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Compressing A Number

http://en.wikipedia.org/wiki/Run-length_encoding might be of some interest too.

Offline

 

#4 2012-10-21 02:54:39

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Compressing A Number

satire, please make sure your posts are helpful and not pointless. pointless messages are considered to be spam. (and btw hash tags don't work on fora)

I can't download the project right now, but I'm assuming your 180 characters are digits. if not, I can't help you.

but you should convert 0-29 to 0-9 and a-t so you have 30 digits in thirty-nary. I'm not sure exactly how it will work, but using a single character for a larger number may help

Offline

 

#5 2012-10-21 18:50:25

MrMokey
Scratcher
Registered: 2009-05-06
Posts: 1000+

Re: Compressing A Number

kayybee wrote:

I can't download the project right now, but I'm assuming your 180 characters are digits. if not, I can't help you.

but you should convert 0-29 to 0-9 and a-t so you have 30 digits in thirty-nary. I'm not sure exactly how it will work, but using a single character for a larger number may help

yes, they are digits. So far they are only 4 costumes.


http://i1193.photobucket.com/albums/aa344/mrmokey1/Thankyouitfitsperfectlysig.png

Offline

 

Board footer